I have a data.frame like the following:
rnum Field Value
1 Car 25.2
1 Bike 20.1
1 Taxi 100.1
2 Car 25.5
2 Bike 19.1
2 Taxi 25.7
I want to create a list of JSON such that, each element of the list is a JSON object is grouped by rnum. Essentially one element of the list should look like this:
{"Car":25.2,"Bike":20.1,"Taxi":100.1,"rnum":"1"}
I tried df %>%group_by(rnum)%>%toJSON() but it yields 3 JSON entries for each row.
Thanks!