Guest User

Untitled

a guest
May 16th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. A B C
  2. 1 5 4.25 4.5
  3. 2 3.5 4 2.5
  4. 3 3.25 4 4
  5. 4 4.25 4.5 2.25
  6. 5 1.5 4.5 3
  7.  
  8. > c(a=5, b=4.25, c=4.5)
  9. a b c
  10. 5.0 4.25 4.5
  11.  
  12. x[r,]
  13.  
  14. #Add your data
  15. x<-structure(list(A = c(5, 3.5, 3.25, 4.25, 1.5), B = c(4.25, 4,
  16. 4, 4.5, 4.5), C = c(4.5, 2.5, 4, 2.25, 3)), .Names = c("A", "B",
  17. "C"), class = "data.frame", row.names = c(NA, -5L))
  18.  
  19. #The vector your result should match
  20. y<-c(A=5, B=4.25, C=4.5)
  21.  
  22. #Test that the items in the row match the vector you wanted
  23. x[1,]==y
  24.  
  25. > d <- data.frame(a=1:3, b=4:6, c=7:9)
  26.  
  27. > d
  28. a b c
  29. 1 1 4 7
  30. 2 2 5 8
  31. 3 3 6 9
  32.  
  33. > d[1, ]
  34. a b c
  35. 1 1 4 7
  36.  
  37. > d[1, ]['a']
  38. a
  39. 1 1
  40.  
  41. x<-structure(list(A = c(5, 3.5, 3.25, 4.25, 1.5), B = c(4.25, 4,
  42. 4, 4.5, 4.5), C = c(4.5, 2.5, 4, 2.25, 3)), .Names = c("A", "B",
  43. "C"), class = "data.frame", row.names = c(NA, -5L))
  44. subset(x, A ==5 & b==4.25 && c==4.5)
Add Comment
Please, Sign In to add comment