[R] Applying do.call to a data.frame using function arguments

hadley wickham h.wickham at gmail.com
Wed Aug 26 18:47:04 CEST 2009


On Wed, Aug 26, 2009 at 11:31 AM,
miller_2555<nabble.30.miller_2555 at spamgourmet.com> wrote:
>
>
> miller_2555 wrote:
>>
>> I'm trying to convert a data.frame to a series of strings (row-wise).
>> There was a very good discussion awhile back (2002) entitled "[R] string
>> concatenate across rows of a matrix??" where Tony Plate recommended the
>> following two alternatives (x2 is an R object of type data frame -- a
>> matrix also works for solution #1):
>>     1) apply(format(x2), 1, paste, collapse=" ");
>>     2) do.call("paste",x2)
>>
>
> Nevermind. Stupid question. The solution is:
> do.call("paste",c(x2,sep='","'));

I think you're missing some quotes:
cat(do.call("paste",c(x2,sep='","'))[1], "\n")

Hadley

-- 
http://had.co.nz/




More information about the R-help mailing list