I'm trying to teach myself R and in doing some sample problems I came across the need to reverse a string.
Here's what I've tried so far but the paste operation doesn't seem to have any effect.
There must be something I'm not understanding about lists? (I also don't understand why I need the [[1]] after strsplit.)
test <- strsplit("greg", NULL)[[1]]
test
# [1] "g" "r" "e" "g"
test_rev <- rev(test)
test_rev
# [1] "g" "e" "r" "g"
paste(test_rev)
# [1] "g" "e" "r" "g"
paste(test_rev, collapse='')
.paste
to behave in a vectorized manner like most other R functions.do.call(paste, as.list(my.atomic))
.[[1]]
afterstrsplit()
, try running this:X <- strsplit(c("abc", "Statistics"), NULL); X; X[[1]]; X[[2]]