Reputation: 449
Given the following data frame:
Date Person Article
---------------------------
01-01-2015 Bob TV
01-01-2015 Bob Video
01-01-2015 Pete Book
02-01-2015 Rob Skate
02-01-2015 Kate TV
How could I convert this data frame to a list of list (or multidimensional array) so, that
my_ist[[01-01-2015]][[Bob]]
would give
TV, Video
?
Upvotes: 2
Views: 1276
Reputation: 9618
What about this?
res <- lapply(split(df, df$V1), function(x) sapply(split(x, x$V2), function(y) y$V3))
res[["01-01-2015"]][["Bob"]]
[1] "TV" "Video"
Upvotes: 2