Whole vector is ok and has no NAs
:
> summary(data$marks)
Min. 1st Qu. Median Mean 3rd Qu. Max.
1.00 6.00 6.00 6.02 7.00 7.00
> length(data$marks)
[1] 2528
However, when trying to calculate a subset using a criteria I receive lots of NAs
:
> summary(data[data$student=="John",]$marks)
Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
1.000 6.000 6.000 6.169 7.000 7.000 464
> length(data[data$student=="John",]$marks)
[1] 523