Hey there, I tried to count the number of rows, where my data isn't NaN in a certain column. this was my guess: (given is a data frame with 2069 rows and 17 cols) NROW(data[jan,16] != NaN) ("jan" is defined this way: jan <- which(data[,2]==1, arr.ind= TRUE)) but I only get the number of columns where my data is "1" in the second col. R isn't removing the NaN. na.rm isn't working here. I would appreciate your help.
?is.nan Peter Ehlers On 2011-02-22 07:11, Sandra Stankowski wrote:> Hey there, > > I tried to count the number of rows, where my data isn't NaN in a > certain column. > > this was my guess: > > (given is a data frame with 2069 rows and 17 cols) > > NROW(data[jan,16] != NaN) > > ("jan" is defined this way: jan<- which(data[,2]==1, arr.ind= TRUE)) > > > but I only get the number of columns where my data is "1" in the second > col. R isn't removing the NaN. > na.rm isn't working here. > > I would appreciate your help. > > ______________________________________________ > 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.
Sandra, Please provide a small, reproducible example of this issue. You probably want to use ?is.nan and not the inequality operator. Similar example, contrast: x <- NA is.na(x) x == NA Sandra Stankowski wrote:> Hey there, > > I tried to count the number of rows, where my data isn't NaN in a > certain column. > > this was my guess: > > (given is a data frame with 2069 rows and 17 cols) > > NROW(data[jan,16] != NaN) > > ("jan" is defined this way: jan <- which(data[,2]==1, arr.ind= TRUE)) > > > but I only get the number of columns where my data is "1" in the second > col. R isn't removing the NaN. > na.rm isn't working here. > > I would appreciate your help. > > ______________________________________________ > 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.