0

I have one column of with 10000 rows, and I want to separate those numbers based on their density. So I use summary() to see a big picture of it, but I got 6 numbers summary, the last one is NA's. But there shouldn't be any NAs, because this is a result of a for loop, and I already eliminate all "inf"s. How can I see where are these NAs and delete them? Here is the result

summary(HOT$score)
Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
0.945   2.714   5.180   5.612   7.976  21.420      97    

Thank you for any idea in advance.

Thanks to all commenters help, I found those NAs. But I can't figure out why it get NA. This is a result of running max(). say

c<-c(21:30)
d<-c(31:40) 
bb<-as.data.frame(cbind(c,d))
h=42
max(bb$c[which(h<bb$c)])
[1] -Inf
Warning message:
In max(bb$c[which(h < bb$c)]) :
no non-missing arguments to max; returning -Inf

so if it doesn't have result, it will return -Inf, I don't know how the result would be NA.

lxcfuji
  • 329
  • 1
  • 4
  • 15
  • possible duplicate of [remove rows with NAs in data.frame](http://stackoverflow.com/questions/4862178/remove-rows-with-nas-in-data-frame) – alko989 Jul 30 '14 at 00:09
  • You probably shouldn't just remove the `NA`'s. Getting unexpected answers like this is usually the result of a bug in the calculations. Look at where you get `NA`'s and if there is a pattern in `HOT[is.na(HOT$score), ]`. – shadow Jul 30 '14 at 06:25

2 Answers2

0

If you want to see which rows have NA's in the column of interest, type HOT[is.na(HOT$score), ]. To remove rows with NAs, see this question.

Community
  • 1
  • 1
Kara Woo
  • 3,595
  • 19
  • 31
0

HOT <- HOT[!is.na(HOT$score),]

should sort you. If you have further problems, leave a comment.

hd1
  • 33,938
  • 5
  • 80
  • 91