How about 

Dat1 <- lapply(subset(Dat, Dat!="P"), My_Function)

--Mark




________________________________
 From: Christofer Bogaso <[email protected]>
To: [email protected] 
Sent: Friday, December 14, 2012 1:58 PM
Subject: [R] A question on list and lapply
 
Dear all, let say I have following list:

Dat <- vector("list", length = 26)
names(Dat) <- LETTERS
My_Function <- function(x) return(rnorm(5))
Dat1 <- lapply(Dat, My_Function)


However I want to apply my function 'My_Function' for all elements of 'Dat' 
except the elements having 'names(Dat) == "P"'. Here I have specified the name 
"P" just for illustration however this will be some name specified by user.

Is there any direct way to achieve this, using 'lapply'?

Thanks for your help.

______________________________________________
[email protected] 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.
        [[alternative HTML version deleted]]

______________________________________________
[email protected] 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