> On Thursday 03 April 2003 01:54, John Miyamoto wrote:

<snippage>

> > 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 <- paste(output, x[i], ...)
> >     output  } #end of function definition
> >
> > paste.vector(x)
> > [1] " Bob loves Sally"
> >
> > Is there a more natural (no loop) way to do this in R?

I might also take this opportunity to note that if paste() didn't have the
collapse=  argument there would still be more elegant way to write the
loop

   do.call("paste",as.list(x))

creates a call to paste() whose arguments are the elements of x.


        -thomas

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to