Re: conversion of string vector into single string

Alan Zaslavsky (zaslavsk@hcp.med.harvard.edu)
Thu, 29 Jan 1998 23:08:14 -0500 (EST)


Use paste(...,collapse=T) or variatnts thereof.

On Thu, 29 Jan 1998, Shawn Boles wrote:

>
> Hi All:
>
> I want to convert a string vector:
>
> ju
> [1] "dcf01" "dcf02a" "dcf02b" "dcf02c" "dcf02d" "dcf02e" "dcf02f" "dcf03"
> >
>
> into a single string:
>
>
> > ju1
> [1] "dcf01 dcf02a dcf01 dcf02a dcf02b dcf02c dcf02d dcf02e dcf02f dcf03"
> >
>
> code below works, _but_ requires a 'for' loop.
>
> ju1<-character()
> > for(i in 1:length(ju)){
> + ju1<-paste(ju1,ju[i])}
> >
>
> Is there a better way?
>
> Thanks in advance,
>
>
> Shawn Boles
>
> Oregon Research Institute Internet: shawn@ori.org
> 1715 Franklin Blvd. Voice: (541) 484-2123 Ext. 225
> Eugene, Oregon /97403-1983 USA Fax: (541) 484-1108
>
> ....................... non nova, sed novae .........................
>