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 d
As @mplourde points out, you want the collapse
argument:
paste(test_rev, collapse='')
Most commands in R are vectorized, but how exactly the command handles vectors depends on the command. paste
will operate over multiple vectors, combining the i
th element of each:
> paste(letters[1:5],letters[1:5])
[1] "a a" "b b" "c c" "d d" "e e"
collapse
tells it to operate within a vector instead.