I'm new to R, and I'm practicing converting JSon to R, then to CSV or Excel. I downloaded the entire Magic the Gathering card set from: https://mtgjson.com/ to practice. I used this code to get it into a "list", but I'd like it in a dataframe or table.
json_file<- rjson::fromJSON(file= "C://Users/ahalman/Desktop/AllCards.json")
I tried:
as.data.frame(json_file)
but I get an error message that says: "Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, : arguments imply differing number of rows: 13, 10, 14, 15, 11, 12, 16, 19, 9, 8, 6, 7, 18, 4, 17, 21, 23, 20, 22"
I thought this would fix it, as I saw it on another Stack Overflow page, but whatever it does, it didn't work:
json_file <- lapply(json_file, function(x) {
x[sapply(x, is.null)] <- NA
unlist(x)
})
Any help would be great. Once it's in a dataframe format, I got this!