[R] detecting null values in a CSV file

Hutchinson,David [PYR] David.Hutchinson at ec.gc.ca
Thu Sep 18 20:12:32 CEST 2008


Try length(na.omit(<the particular data column>))

Here's an example:

data <- runif(100,0,10)
data[runif(20,0,100)] <- NA
file.contents <- matrix(data, ncol = 5, byrow = TRUE)
for (i in 1:5) {
  print (length(na.omit(file.contents[,i])))
}
 

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of Jason Thibodeau
Sent: Thursday, September 18, 2008 10:12 AM
To: r-help at r-project.org
Subject: [R] detecting null values in a CSV file

Hello all,

I have a CSV file, that is 2411 columns wide. There are certain
instances in
teh file, where null values are located. That is: two commas together,
without anything in the middle. In a certain section, the only possible
values are NULL, 0,1,and 2. I need to be able to detect these NULL's and
be
able to have them counted. For example, in a frequency table. How can I
accomplish this?

Thanks in advance for the help.

-- 
Jason Thibodeau

	[[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