Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # origin type amount
- 1 1 t1 100
- 2 1 t2 100
- 3 1 t3 100
- 4 2 t1 100
- 5 2 t2 100
- 6 1 t1 100
- # t1 t2 t3
- 1 200 100 100
- 2 100 100 NA
- xtabs(amount~origin + type, df1)
- with(df1, tapply(amount, list(origin, type), FUN = sum))
- # t1 t2 t3
- #1 200 100 100
- #2 100 100 NA
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement