Guest User

Untitled

a guest
Dec 13th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. data <- structure(list(Sample = 1:14, Head = c(1L, 0L, NA, 1L, 1L, 1L,
  2. 0L, 0L, 1L, 1L, 1L, 1L, 0L, 1L), Shoulders = c(13L, 14L, NA,
  3. 18L, 10L, 24L, 53L, NA, 86L, 9L, 65L, 87L, 54L, 36L), Knees = c(1L,
  4. 1L, NA, 1L, 1L, 2L, 3L, 2L, 1L, NA, 2L, 3L, 4L, 3L), Toes = c(324L,
  5. 5L, NA, NA, 5L, 67L, 785L, 42562L, 554L, 456L, 7L, NA, 54L, NA
  6. )), .Names = c("Sample", "Head", "Shoulders", "Knees", "Toes"
  7. ), class = "data.frame", row.names = c(NA, -14L))
  8.  
  9. just.samples.with.shoulder.values <- data[complete.cases(data[,"Shoulders"])]
  10. print(just.samples.with.shoulder.values)
  11.  
  12. data[!is.na(data["Shoulders"]),]
  13. Sample Head Shoulders Knees Toes
  14. 1 1 1 13 1 324
  15. 2 2 0 14 1 5
  16. 4 4 1 18 1 NA
  17. 5 5 1 10 1 5
  18. 6 6 1 24 2 67
  19. 7 7 0 53 3 785
  20. 9 9 1 86 1 554
  21. 10 10 1 9 NA 456
  22. 11 11 1 65 2 7
  23. 12 12 1 87 3 NA
  24. 13 13 0 54 4 54
  25. 14 14 1 36 3 NA
  26.  
  27. data[complete.cases(data$Shoulders), ]
  28. # Sample Head Shoulders Knees Toes
  29. # 1 1 1 13 1 324
  30. # 2 2 0 14 1 5
  31. # 4 4 1 18 1 NA
  32. # 5 5 1 10 1 5
  33. # 6 6 1 24 2 67
  34. # 7 7 0 53 3 785
  35. # 9 9 1 86 1 554
  36. # 10 10 1 9 NA 456
  37. # 11 11 1 65 2 7
  38. # 12 12 1 87 3 NA
  39. # 13 13 0 54 4 54
  40. # 14 14 1 36 3 NA
Add Comment
Please, Sign In to add comment