0

It's the first time I've had to manipulate a .json file, I'm unsure how to transform nested objects into columns. See the example.

library(jsonlite)
TEST < - fromJSON(‘C:/FOLDER/FILE.json’) %>% as.data.frame()

The file is imported correctly, however, some columns, according to the print, have variables nested within the same column. I would like to know how it is possible to transform these variables nested in columns within the file (TEST).

enter image description here

5
  • Please show a small reproducible example with expected output Commented Dec 10, 2021 at 16:36
  • I would like to show more information, but I cannot (I still don't know) extract this information. When I hover the mouse over this variable, a pop-up appears written: list (name of all variables) Commented Dec 10, 2021 at 16:54
  • Can you try TEST %>% unpack(where(is.data.frame)) Commented Dec 10, 2021 at 16:55
  • 1
    Issue with your image is that we cannot test. So, can only suggest some codes which may or may not work Commented Dec 10, 2021 at 17:07
  • Does the solution below yolve your problem? Commented Dec 12, 2021 at 12:25

1 Answer 1

1

You could try:

library(jsonlite)
library(rrapply)

TEST <- rrapply(fromJSON(‘C:/FOLDER/FILE.json’), how = 'melt')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.