0
votes

I have a dataset in R with many observations and one column with rows which look like this:

[{'name': 'example1', 'parameters': ['par1', 'par2', 'par3'], 'values': ['value1', 'value2', 'value3']}

The 'parameters' are equal for each 'name'. If I understand correctly in others languages this is commonly known as a dictionary. Now for an analysis I need to create 3 new columns named 'par1', 'par2' and 'par3' with values 'value1', 'value2' and 'value3' for each row. Even though 'name' can differ there are little enough different names such that I can subset the dataset to get around this.

Is there any function or package in R which can do this automatically?

I can, of course, do something with substring or the like but this would be quite a bit of work.

1

1 Answers

0
votes

Alright so if anybody sees this and is also looking for an answer, I solved the issue by using gsub to remove all extra characters and the 'name', 'parameters' and 'values' strings. Then you can use sapply in combination with strsplit to create new columns of for instance the 7th value in the column of strings that's left. Do this for all your variables and you get a dataset. Bit more work than you would want but it works.