[R] String question

Petr PIKAL petr.pikal at precheza.cz
Wed Dec 23 13:10:42 CET 2009


Hi

r-help-bounces at r-project.org napsal dne 23.12.2009 12:08:02:

> 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

Isn't it same like

> paste(temp, collapse=",")
[1] "November,December,Monday,Tuesday"

I also thought you actually wanted

> paste(paste(temp, seq_along(temp), sep="."), collapse=",")
[1] "November.1,December.2,Monday.3,Tuesday.4"

Regards
Petr


> 
> but I have no idea where I could find that documentation ;-)
> 
> Thanks a lot
> Knut
> 
> ______________________________________________
> R-help at r-project.org 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.




More information about the R-help mailing list