Reputation: 2293
I'm getting an error message when exporting data to CSV. The code I'm using is as follows:
library(jsonlite)
energy <- "https://cdn.rawgit.com/christophergandrud/networkD3/master/JSONdata/energy.json" %>%
fromJSON
file <- c("C://Users//x////sankeyData.txt")
write.table(energy, file, sep="\t")
The error message I'm getting is the following: Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, : arguments imply differing number of rows: 48, 68
Any ideas on what am I doing wrong?
Thanks
Upvotes: 0
Views: 449
Reputation: 1181
Variable energy
is a list of two data frames (nodes
with 48 rows and links
with 68 rows). If you want to save this list something like this will work:
file <- c("C://Users//x////sankeyData.rds")
saveRDS(object = energy, file = file)
In case you want two data frames saved then apply function write.table
twice for each data frame with different file names.
Upvotes: 3