Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # create dataframe
- df <- data.frame(id = c('a', 'b'), item1 = c('香蕉', '豆子'), item2 = c('瑪奇朵', '山葵'), item3 = c('老虎', '蘋果'), stringsAsFactors = FALSE)
- # use reshape2::melt function
- melt(df, id.vars = 'id', measure.vars = c('item1', 'item2', 'item3'), variable.name = 'item') %>% select(-item)
Add Comment
Please, Sign In to add comment