Hi, I have a very simple doubt. Look: > teste <- c("A","B","C") > teste2 <- paste(teste[1],teste[2],teste[3],sep="+") > teste2 [1] "A+B+C" > How to make it automatic, like I try to use paste(teste,sep="+") but the paste dont get the teste elements separately to join again in a unique element. Exist any function to associated with paste make this result more automatically. Thanks Ronaldo -- 17? lei - Seu orientador quer que voc? se torne famoso, de modo que ele possa, finalmente, se tornar famoso. --Herman, I. P. 2007. Following the law. NATURE, Vol 445, p. 228.> Prof. Ronaldo Reis J?nior| .''`. UNIMONTES/DBG/Lab. Ecologia Comportamental e Computacional | : :' : Campus Universit?rio Prof. Darcy Ribeiro, Vila Mauric?ia | `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil | `- Fone: (38) 3229-8192 | ronaldo.reis at unimontes.br | http://www.ppgcb.unimontes.br/lecc | LinuxUser#: 205366
paste(teste, collapse="+") ciao! mario On 08-Apr-11 12:44, Ronaldo Reis Junior wrote:> teste <- c("A","B","C")-- Ing. Mario Valle Data Analysis and Visualization Group | http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82
Hi, try paste(teste,collapse="+") cheers. Am 08.04.2011 12:44, schrieb Ronaldo Reis Junior:> Hi, > > I have a very simple doubt. > > Look: > >> teste <- c("A","B","C") > >> teste2 <- paste(teste[1],teste[2],teste[3],sep="+") >> teste2 > [1] "A+B+C" >> > > How to make it automatic, like I try to use paste(teste,sep="+") but the > paste dont get the teste elements separately to join again in a unique > element. > > Exist any function to associated with paste make this result more > automatically. > > Thanks > Ronaldo >-- Eik Vettorazzi Institut f?r Medizinische Biometrie und Epidemiologie Universit?tsklinikum Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790
> Exist any function to associated with paste make this result more automatically.you can try with gsub. Alfredo 2011/4/8 Ronaldo Reis Junior <chrysopa at gmail.com>:> Hi, > > I have a very simple doubt. > > Look: > >> teste <- c("A","B","C") > >> teste2 <- paste(teste[1],teste[2],teste[3],sep="+") >> teste2 > [1] "A+B+C" >> > > How to make it automatic, like I try to use paste(teste,sep="+") but the > paste dont get the teste elements separately to join again in a unique > element. > > Exist any function to associated with paste make this result more > automatically. > > Thanks > Ronaldo > > -- > 17? lei - Seu orientador quer que voc? se torne famoso, > ? ? ? ? ?de modo que ele possa, finalmente, se tornar famoso. > > ? ? ?--Herman, I. P. 2007. Following the law. NATURE, Vol 445, p. 228. > >> ?Prof. Ronaldo Reis J?nior > > | ?.''`. UNIMONTES/DBG/Lab. Ecologia Comportamental e Computacional > | : :' ?: Campus Universit?rio Prof. Darcy Ribeiro, Vila Mauric?ia > | `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil > | ? `- Fone: (38) 3229-8192 | ronaldo.reis at unimontes.br > | http://www.ppgcb.unimontes.br/lecc | LinuxUser#: 205366 > > ______________________________________________ > 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. >
On 04/08/2011 08:44 PM, Ronaldo Reis Junior wrote:> Hi, > > I have a very simple doubt. > > Look: > > > teste <- c("A","B","C") > > > teste2 <- paste(teste[1],teste[2],teste[3],sep="+") > > teste2 > [1] "A+B+C" > > > > How to make it automatic, like I try to use paste(teste,sep="+") but the > paste dont get the teste elements separately to join again in a unique > element. > > Exist any function to associated with paste make this result more > automatically. >Hi Ronaldo, Try: paste(teste,collapse="+") Jim