0

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

1 Answer 1

3

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.

0

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.