I have the dataframe below:
name<-c("Jack","Bob","Jack","Bob")
item<-c("apple","olive","banana","tomato")
d<-data.frame(name,item)
name item
1 Jack apple
2 Bob olive
3 Jack banana
4 Bob tomato
and I would like to create a list which will include as many lists as the unique values of name
and each one will include the values of item
that correspond to that name
. The new list will be like:
words
[[1]]
[1] "apple" "banana"
[[2]]
[1] "olive" "tomato"
if instead of [[1]]
and [[2]]
I could have the actual values of name
that correspond, [[Jack]]
and [[Bob]]
it would be good as well.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…