[R] how to concatinate the elements of some text vectors cat() or print() ?
John Kane
jrkrideau at yahoo.ca
Wed May 2 15:41:03 CEST 2007
I have some comment text taken from a SAS data file.
It is stored in two vectors and is difficult to read.
I would like to simply concatentate the individual
entries and end up with a character vector that give
me one line of text per comment.
I cannot see how to do this, yet it must be very easy.
I have played around with cat() and print with no
success. Would someone kindly point out where I
am going wrong?
Thanks
Simple Example:
aa <- LETTERS[1:5]
bb <- letters[1:5]
cat(aa[1], bb[1]) # works for individuals
cat(aa,bb) #(concatinates entire vectors)
# Using sink I might get it to work if I could figure
out how to escape a
# new line command. encodeString does not seem
appropriate here.
harry <- c(rep(NA,5))
for (i in 1:5 ) {
cat (aa[i],bb[i])
}
More information about the R-help
mailing list