I'm attempting to convert a csv into JSON format for the first time. When the csv is read into R, it's in the following data frame format:
col1 col2 col3
1 a def1
1 b def2
2 c def3
2 a def1
Ideally, I'd like to iterate through the dataframe, find the unique combinations of the three columns, and separate the key/value pairs for the JSON into the following:
{ "1":["a", "def1"], ["b", "def2"], "2":["a", "def1"], ["c", "def3"]}
I can only think of ways to achieve this in python, but I'm having difficulties executing this in R. Any suggestions on how to get this started?