Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Name A B C
- apple 1 -1 0
- banana 2 -2 1
- pear -3 0 1
- df[-1] <- sign(df[-1]) * -1
- df
- # Name A B C
- #1 apple -1 1 0
- #2 banana -1 1 -1
- #3 pear 1 0 -1
- df <- structure(list(Name = structure(1:3, .Label = c("apple", "banana",
- "pear"), class = "factor"), A = c(-1, -1, 1), B = c(1, 1, 0),
- C = c(0, -1, -1)), .Names = c("Name", "A", "B", "C"), row.names = c(NA,
- -3L), class = "data.frame")
Add Comment
Please, Sign In to add comment