Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(dplyr)
- library(tidyr)
- dat <- data.frame(id = c('a','b'), item1 = c('香蕉','豆子'),
- item2 = c('瑪奇朵','山葵'), item3 = c('老虎','蘋果'),
- stringsAsFactors = FALSE)
- dat %>% gather(item,n,-id) %>% arrange(id) %>% select(-item)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement