Hi muting,
# your data
muting <- data.frame(col1 = c(1,1,2,1,2,1), col2=c(NA,1,2,1,2,NA))
# 1. finding rows with NA
is.na(muting)
# 2. counting the NAs per column
colSums(is.na(muting))
# 3. keeping only the ones without NAs
muting[,colSums(is.na(muting)) == 0]
Regards,
Stefan
schrieb muting, Am 14.04.2010 16:56:
Hi everyone:
I have a dataset:
tm1
col1 col2
[1,] 1 NA
[2,] 1 1
[3,] 2 2
[4,] 1 1
[5,] 2 2
[6,] 1 NA
I need to delete entire column 2 that has NA in it(not all of them are NAs),
and the result I want is
tm1
col1
[1,] 1
[2,] 1
[3,] 2
[4,] 1
[5,] 2
[6,] 1
what should I do?
I search a lot, all I found is how to delete column with all NA values..
Thanks a lot
muting
______________________________________________
[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.