On Jan 2, 2013, at 9:00 AM, eliza botto wrote:


Dear useRs,
i have a data frame with 16 lists in it. each list has variable number of lines. i want to create a loop which will start deleting every 32nd line in each list, till the end of each list. more precisely if a list has 200 rows i want to delete row number 32, 64, 96 and so on...for that i created the followng loop.
e<-lapply(seq(1),function(i) rbind(r[[i]][1:31,],(r[[i]] [32:nrow(r[[i]]),][-seq(i,nrow(r[[i]]),32),])))
but this loop executes the desired operation on the list at the top and doesnt do anything to the remaining 16 lists.
any help?thanks in advance
eliza                                   
        [[alternative HTML version deleted]]


Perhaps something like this untested code:

smaller.r <- lapply(r, function(x) x[ ! ( 1:200 %% 32 == 0) ] ) # logical indexing

You _should_ have constructed a small example and posted the results of dput on that list.

--


David Winsemius, MD
Alameda, CA, USA

______________________________________________
R-help@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.

Reply via email to