I have a data like this :
df<-structure(list(concept = c("agree", "anger", "anxiety", "cognitive",
"cognitive"), count = c(1L, 2L, 4L, 6L, 122L)), class = "data.frame", row.names = c(NA,
-5L))
I need to have new columns for each value of the "concept" column that get the number in the "count" column and the desire data is :
new_df<-structure(list(agree = c(1L, 0L, 0L, 0L, 0L), anger = c(0L, 2L,
0L, 0L, 0L), anxiety = c(0L, 0L, 4L, 0L, 0L), cognitive = c(0L,
0L, 0L, 6L, 122L)), class = "data.frame", row.names = c(NA, -5L
))
agree anger anxiety cognitive
1 1 0 0 0
2 0 2 0 0
3 0 0 4 0
4 0 0 0 6
5 0 0 0 122