Re: [R] Combining the components of a character vector

2003-04-04 Thread Thomas Lumley
> On Thursday 03 April 2003 01:54, John Miyamoto wrote: > > The following function combines the character vector into a string > > in the way that I want, but it seems somewhat inelegant. > > > > paste.vector <- function(x, ...) { > > output <- NULL > > for (i in 1:length(x)) output <- p

RE: [R] Combining the components of a character vector

2003-04-04 Thread Adaikalavan Ramasamy
Yes there is. > x <- c("Bob", "loves", "Sally") > paste(x, collapse=" ") [1] "Bob loves Sally" -Original Message- From: John Miyamoto [mailto:[EMAIL PROTECTED] Sent: Thursday, April 03, 2003 7:54 AM To: R discussion group Subject: [R] Combining the components of a character vector De

Re: [R] Combining the components of a character vector

2003-04-04 Thread Ray Brownrigg
>Suppose I have a character vector. > > x <- c("Bob", "loves", "Sally") > > I want to combine it into a single string: "Bob loves Sally" . > paste(x) yields: > paste(x) > [1] "Bob" "loves" "Sally" > > Is there a more natural (no loop) way to do this in R? > RTFM: > paste(x, collapse=" ")

Re: [R] Combining the components of a character vector

2003-04-04 Thread Pierre Kleiber
Try the "collapse" argument in paste(), i.e. paste(x,collapse=" ") John Miyamoto wrote: Dear Help, Suppose I have a character vector. x <- c("Bob", "loves", "Sally") I want to combine it into a single string: "Bob loves Sally" . paste(x) yields: paste(x) [1] "Bob" "loves" "Sally" The foll

Re: [R] Combining the components of a character vector

2003-04-04 Thread Jerome Asselin
Please, have a closer look at the help file for paste(), and use the "collapse" arguments. Jerome On April 2, 2003 03:54 pm, John Miyamoto wrote: > Dear Help, >Suppose I have a character vector. > > x <- c("Bob", "loves", "Sally") > > I want to combine it into a single string: "Bob loves S

Re: [R] Combining the components of a character vector

2003-04-04 Thread Tony Plate
From ?paste: If a value is specified for `collapse', the values in the result are then concatenated into a single string, with the elements being separated by the value of `collapse'. > paste(c("Bob", "loves", "Sally"), collapse=" ") [1] "Bob loves Sally" > At Wednesday 03:54 PM 4/2/

Re: [R] Combining the components of a character vector

2003-04-04 Thread Spencer Graves
paste( c("Bob", "loves", "Sally"), collapse=" ") Spencer Graves John Miyamoto wrote: Dear Help, Suppose I have a character vector. x <- c("Bob", "loves", "Sally") I want to combine it into a single string: "Bob loves Sally" . paste(x) yields: paste(x) [1] "Bob" "loves" "Sally" The followin

Re: [R] Combining the components of a character vector

2003-04-04 Thread Jean-Pierre . Mueller
At 15:54 -0800 2.4.2003, John Miyamoto wrote: >Dear Help, > Suppose I have a character vector. > >x <- c("Bob", "loves", "Sally") > >I want to combine it into a single string: "Bob loves Sally" . >[...] >Is there a more natural (no loop) way to do this in R? > >John Miyamoto paste(x, sep = "",

Re: [R] Combining the components of a character vector

2003-04-04 Thread John Fox
Dear John, Try paste(x, collapse=" ") John At 03:54 PM 4/2/2003 -0800, John Miyamoto wrote: Dear Help, Suppose I have a character vector. x <- c("Bob", "loves", "Sally") I want to combine it into a single string: "Bob loves Sally" . paste(x) yields: paste(x) [1] "Bob" "loves" "Sally" The

Re: [R] Combining the components of a character vector

2003-04-04 Thread Douglas Bates
Use the collapse argument to paste. > paste(c('Bob', 'loves', 'Sally'), collapse = ' ') [1] "Bob loves Sally" John Miyamoto <[EMAIL PROTECTED]> writes: >Suppose I have a character vector. > > x <- c("Bob", "loves", "Sally") > > I want to combine it into a single string: "Bob loves Sally"

Re: [R] Combining the components of a character vector

2003-04-04 Thread Ben Bolker
paste(x,collapse=" ") On Wed, 2 Apr 2003, John Miyamoto wrote: > Dear Help, >Suppose I have a character vector. > > x <- c("Bob", "loves", "Sally") > > I want to combine it into a single string: "Bob loves Sally" . > paste(x) yields: > paste(x) > [1] "Bob" "loves" "Sally" > > The fo

RE: [R] Combining the components of a character vector

2003-04-04 Thread Wiener, Matthew
The collapse argument does what you want: x <- c("Bob", "loves", "Sally") paste(c, collapse = " ") Hope this helps, Matt Wiener -Original Message- From: John Miyamoto [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 02, 2003 6:54 PM To: R discussion group Subject: [R] Combining the com

Re:[R] Combining the components of a character vector

2003-04-04 Thread Peter Wolf
John Miyamoto wrote: > Suppose I have a character vector. > x <- c("Bob", "loves", "Sally") > > I want to combine it into a single string: "Bob loves Sally" . > paste(x) yields: > paste(x) > [1] "Bob" "loves" "Sally" > Try: > paste(x,collapse=" ") and > help(paste) --Peter -

Re: [R] Combining the components of a character vector

2003-04-04 Thread Stephen C. Upton
John, Try paste with collapse argument: > x <- c("Bob", "loves", "Sally") > paste(x,collapse=" ") [1] "Bob loves Sally" HTH steve John Miyamoto wrote: > Dear Help, >Suppose I have a character vector. > > x <- c("Bob", "loves", "Sally") > > I want to combine it into a single string: "Bob lo

Re: [R] Combining the components of a character vector

2003-04-04 Thread vito muggeo
> x <- c("Bob", "loves", "Sally") > paste(x,collapse=" ") [1] "Bob loves Sally" best, vito - Original Message - From: "John Miyamoto" <[EMAIL PROTECTED]> To: "R discussion group" <[EMAIL PROTECTED]> Sent: Thursday, April 03, 2003 1:54 AM Subject: [R] Combining the components of a charac

Re: [R] Combining the components of a character vector

2003-04-04 Thread Ido M. Tamir
On Thursday 03 Apr 2003 1:54 am, John Miyamoto wrote: > Dear Help, >Suppose I have a character vector. > > x <- c("Bob", "loves", "Sally") > > I want to combine it into a single string: "Bob loves Sally" . y <- paste(c, collapse=" ") best wishes Ido

Re: [R] Combining the components of a character vector

2003-04-04 Thread Torsten Hothorn
> Dear Help, >Suppose I have a character vector. > > x <- c("Bob", "loves", "Sally") > > I want to combine it into a single string: "Bob loves Sally" . > paste(x) yields: > paste(x) > [1] "Bob" "loves" "Sally" > R> x <- c("Bob", "loves", "Sally") R> paste(x, collapse=" ") [1] "Bob loves Sal

Re: [R] Combining the components of a character vector

2003-04-04 Thread Achim Zeileis
On Thursday 03 April 2003 01:54, John Miyamoto wrote: > Dear Help, >Suppose I have a character vector. > > x <- c("Bob", "loves", "Sally") > > I want to combine it into a single string: "Bob loves Sally" . > paste(x) yields: > paste(x) > [1] "Bob" "loves" "Sally" R> x <- c("Bob", "loves",

RE: [R] Combining the components of a character vector

2003-04-04 Thread strumila network systems
paste(x,collapse=" ") -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of John Miyamoto Sent: Thursday, 3 April 2003 9:54 AM To: R discussion group Subject: [R] Combining the components of a character vector Dear Help, Suppose I have a character vector. x <

Re: [R] Combining the components of a character vector

2003-04-04 Thread Peter Dalgaard BSA
John Miyamoto <[EMAIL PROTECTED]> writes: > Dear Help, >Suppose I have a character vector. > > x <- c("Bob", "loves", "Sally") > > I want to combine it into a single string: "Bob loves Sally" . > paste(x) yields: > paste(x) > [1] "Bob" "loves" "Sally" Like this: > paste(x,collapse=" ")