I have a data frame and want to add an additional column that contains the data per row in JSON format. In this example:
dfr = data.frame(name = c("Andrew", "Mathew", "Dany", "Philip", "John", "Bing", "Monica"), age = c(28, 23, 49, 29, 38, 23, 29))
dfr %>% mutate(Payload = jsonlite::toJSON(dfr))
I would like to get
Andrew 28 {"name":"Andrew","age":28}
Mathew 23 {"name":"Mathew","age":23}
Instead I get per row the JSON string for the complete data frame.
I tried it with apply
but I fail to get it to run.