[R] String question
Jim Lemon
jim at bitwrit.com.au
Wed Dec 23 11:50:09 CET 2009
On 12/23/2009 09:21 PM, Knut Krueger wrote:
> Hi to all
>
> I need a string like
> temp <- paste("m1","m2","m3",sep=",")
> But i must know how many items are in the string,afterwards
> the other option would be to use a vector
> temp <- c("m1","m2","m3")
> No problem to get the count of items but I must get afterwards the
> string "m1,m2,m3"
> No problem to build the string with a loop, but it should be more easy
> but it seems that I am looking to the wrong functions.
>
Hi Knut,
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=","))
Jim
More information about the R-help
mailing list