[R] how to concatinate the elements of some text vectors cat() or print() ?

Liaw, Andy andy_liaw at merck.com
Wed May 2 16:08:19 CEST 2007


Is paste() what you're looking for?

Andy 

From: John Kane
> 
> 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])
>  }
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 
> 


------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments,...{{dropped}}



More information about the R-help mailing list