I have a nested list that contains country names. I want to count the frequency of the countries, whereby +1 is added with each mention in a sub-list (regardless of how often the country is mentioned in that sub-list).
For instance, if I have this list:
[[1]]
[1] "Austria" "Austria" "Austria"
[[2]]
[1] "Austria" "Sweden"
[[3]]
[1] "Austria" "Austria" "Sweden" "Sweden" "Sweden" "Sweden"
[[4]]
[1] "Austria" "Austria" "Austria"
[[5]]
[1] "Austria" "Japan"
... then I would like the result to be like this:
country freq
====================
Austria 5
Sweden 2
Japan 1
I have tried various ways with lapply
, unlist
, table
, etc. but nothing worked the way I would need it. I would appreciate your help!