I have a dataframe with ids of participants as a first, and and their responses as json array as a second column. So it is basically a data frame with 240 observations: 240 participant codes, and 240 arrays with 13 responses in each observation that can be converted into a 3X10 array each Looking like something like that:
I convert json into a dataframe using jsonlite::fromJSON
, and as a result I get a list of data.frames (shortened up for the simplicity):
[[1]]
case_n d1 d2
1 13 0 100
2 12 100 0
3 11 0 100
[[2]]
case_n d1 d2
1 12 50 50
2 8 50 50
3 3 50 50
[[3]]
case_n d1 d2
1 11 50 50
2 7 50 50
3 13 50 50
I know that these can be merged into one large dataframe containing all dataframes for example using plyr::ldply
df <- ldply(converted_json, data.frame)
What is the way to correctly merge this extended df
with initial participant.code
?
So the wanted result would be something like;
partcode case_n d1 d2
8pdpaqyv 11 50 50
8pdpaqyv 7 50 50
8pdpaqyv 13 50 50
3q8o3mry 11 50 50
3q8o3mry 7 50 50
3q8o3mry 13 50 50
1kueczzz 11 50 50
1kueczzz 7 50 50
1kueczzz 13 50 50
UPDATE: the task is a bit different from this question, because I also need to store the ids from the initial data.