Reputation: 1144
I have a key / value list in R called country :
print(country)
$CAM
[1] 5
$TJK
[1] 1
$SEN
[1] 7
the key is the name of a country and the value an occurence of this one.
And i would like to convert this list as a dataframe like ths :
country occurence
0 CAM 5
0 TJK 1
0 SEN 7
thanks and regards
Upvotes: 1
Views: 1031
Reputation: 70256
You can unlist and stack the input-list:
stack(unlist(country))
# values ind
#1 5 CAM
#2 1 TJK
#3 7 SEN
Upvotes: 7