I am trying to get a data frame ( just.samples.with.shoulder.values , say) that contains only samples that have NA values. I tried to accomplish this with the complete.cases function, but I suppose I'm doing something wrong syntactically below:
data <- structure(list(Sample = 1:14, Head = c(1L, 0L, NA, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 0L, 1L), Shoulders = c(13L, 14L, NA, 18L, 10L, 24L, 53L, NA, 86L, 9L, 65L, 87L, 54L, 36L), Knees = c(1L, 1L, NA, 1L, 1L, 2L, 3L, 2L, 1L, NA, 2L, 3L, 4L, 3L), Toes = c(324L, 5L, NA, NA, 5L, 67L, 785L, 42562L, 554L, 456L, 7L, NA, 54L, NA )), .Names = c("Sample", "Head", "Shoulders", "Knees", "Toes" ), class = "data.frame", row.names = c(NA, -14L)) just.samples.with.shoulder.values <- data[complete.cases(data[,"Shoulders"])] print(just.samples.with.shoulder.values)
I would also be interested to know if some other route (using subset() , let's say) is a wiser idea. Thank you for help!