[R] How to Turn OFF Vectors Recycling Rule in Paste()
Preeti ranjan Pradhan
preetiranjan.2008 at gmail.com
Thu Aug 27 00:43:11 CEST 2015
Hello Team,
Platform:Windows 7 32-bit
R Version:3.2.2
I have two vectors as follows
> S = c("aa", "bb", "cc", "dd", "ee")
> X= c("aa", "bb", "cc", "dd")
When I trying a paste function
> z=paste(S,X)
> z
I am getting result as
[1] "aa aa" "bb bb" "cc cc" "dd dd" "ee aa"
I don't need the last element of S vector should get concatenated with
first element of X vector rather than it should take a space or null value
for concatenation. If I specify explicit space value in X vector like
> X= c("aa", "bb", "cc", "dd", " ")
Then I am getting result as
> z=paste(S,X)
> z
[1] "aa aa" "bb bb" "cc cc" "dd dd" "ee "
Could you please suggest me how to turn off the Vector recycle in paste
function?
Thanks and Regards
Preetiranjan Pradhan
[[alternative HTML version deleted]]
More information about the R-help
mailing list