[R] Very simple question

Jim Lemon jim at bitwrit.com.au
Fri Apr 8 13:49:03 CEST 2011


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



More information about the R-help mailing list