[R] String question
     (Ted Harding) 
    Ted.Harding at manchester.ac.uk
       
    Wed Dec 23 12:28:50 CET 2009
    
    
  
On 23-Dec-09 11:08:02, Knut Krueger wrote:
> Jim Lemon schrieb:
>> Not as easy as I thought it would be, but:
>>
>> mlist<-as.list(paste("m",1:sample(5:10,1),sep=""))
>> do.call("paste",c(mlist,sep=","))
> 
> Hi Jim,
> yes it works  :-)
> 
> temp <- c("November", "December","Monday","Tuesday")
> length(temp) #getting the length of the vector
> string1=do.call("paste",c(as.list(temp),sep=",")) #converting to a
> string
> 
> but I have no idea where I could find that documentation ;-)
> 
> Thanks a lot
> Knut
Interestingly, cat() does the pasting job in the simplest
possible way:
> temp <- c("November", "December","Monday","Tuesday")
> cat(temp,sep=",")
November,December,Monday,Tuesday> 
[copied from the R console; note the trialing ">" which is
 the command prompt for the next input -- not part of the
 output of cat() ]
with output to screen (or to nominated file). But there
seems to be no way to persuade cat to *return* this result
as a value, which could be assigned to a variable.
If there were such a way, that would be a very smooth solution!
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 23-Dec-09                                       Time: 11:28:47
------------------------------ XFMail ------------------------------
    
    
More information about the R-help
mailing list