Skip to content
Prev 313103 / 398506 Next

do.call

Hi Dominic,
In that case, this might help you.
set.seed(15)
datos<-as.data.frame(matrix(sample(c(1:20,NA),30,replace=TRUE),ncol=6))
do.call(rbind,lapply(split(datos,1:nrow(datos)),function(x) paste(x[!is.na(x)],collapse=";")))
?# [,1]????????????? 
#1 "13;3;18;17;14"?? 
#2 "5;18;14;10;17;3" 
#3 "6;11;8;4"??????? 
#4 "14;15;15;3;2;20" 
#5 "8;18;19;17;12;11"
A.K.


----- Original Message -----
From: Dominic Roye <dominic.roye at gmail.com>
To: arun <smartpink111 at yahoo.com>
Cc: 
Sent: Thursday, December 6, 2012 9:33 AM
Subject: Re: [R] do.call

Well, my aim is to get a new column that looks like this without NA
but with all of the values in the columns and rows:

200.4;608.1; ...
360.0
420.6;608.0; ...
100.1;905.0
.
.
.

in the original data, each value has its own column. Each column has
different number of values, therefore arise NA.

Thanks for your help!


2012/12/6 arun <smartpink111 at yahoo.com>:
Message-ID: <1354806054.27882.YahooMailNeo@web142606.mail.bf1.yahoo.com>
In-Reply-To: <CALvVS-G4qkaJHS5P13M2g1cEjt7r9XAU_Rf4+0JS-Ra1=Q4Mjw@mail.gmail.com>