[R] Logical operator and lists

arun smartpink111 at yahoo.com
Tue Jan 8 17:26:14 CET 2013


HI,
This should also work:

 set.seed(5)
 list1<-lapply(1:3,function(i) data.frame(col1=sample(c(1:5,""),10,replace=TRUE), value=rnorm(10),stringsAsFactors=FALSE))

 lapply(list1,function(x) {x[x==""]<-NA;x})
A.K.

----- Original Message -----
From: Dominic Roye <dominic.roye at gmail.com>
To: R help <r-help at r-project.org>
Cc: 
Sent: Tuesday, January 8, 2013 7:16 AM
Subject: [R] Logical operator and lists

Hello R-Helpers,

I have a slight problem with the expresion data[data==""] <- NA which works
well for a data.frame. But now i must use the same for a list of
data.frames.

My idea is data[[]][data==""] but it don´t work.

Thanks!!

Dominic

    [[alternative HTML version deleted]]


______________________________________________
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