[R] do.call

arun smartpink111 at yahoo.com
Tue Dec 4 14:07:18 CET 2012


Hi,
Try this:
set.seed(15)
datos<-as.data.frame(matrix(sample(c(1:20,NA),30,replace=TRUE),ncol=6))
 do.call(paste,c(na.omit(datos),sep=";"))
#[1] "5;18;14;10;17;3"  "14;15;15;3;2;20"  "8;18;19;17;12;11"

A.K.



----- Original Message -----
From: Dominic Roye <dominic.roye at gmail.com>
To: r-help at r-project.org
Cc: 
Sent: Tuesday, December 4, 2012 7:38 AM
Subject: [R] do.call

Hello,

I have a problem with the "do.call-function". I would like to merge
the values of more than 30 columns, but not in all of the rows exist
values, so with this commando i get a lot of ";" or NA.

How get i only the merge of cells with a number?


datos$NEW <- do.call(paste, c(datos[,19:53], sep = ";"))


$ NEW                              : chr
"218.0;;;;;;;;;;;;;;;;;;;;;;;;NA;;;NA;;;NA;NA;NA;NA;NA


I hope you can help me. Thanks!

Best regards,

Dominic

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.





More information about the R-help mailing list