Home > Software engineering >  Why does my working directory not function - R
Why does my working directory not function - R

Time:04-25

I recently started using R, and it seems my working directories never work. I've been trying to simply turn a JSON document into a file on my desktop (to simplify things), but it does not do anything. The weird thing is that it also does not display an error message.

Could someone please help?

library ("jsonlite")
library ("ggplot2")
library ("stringr")
library ("arules")

setwd("~/Desktop")


tmp <- readLines("https://pomber.github.io/covid19/timeseries.json")
jsonLot <- fromJSON(tmp)

myjsonLot <- toJSON(jsonLot, pretty=TRUE)
print(myjsonLot)
View(myjsonLot)
fileConn <- file(paste0("~/Desktop", "Covid19_timeseries.json"))
writeLines(myjsonlot, fileConn)
close(fileConn)

CodePudding user response:

This document is around 17mb. Since you are not manipulating it in any way, i would rather download it directly instead on trying to load it to memory: Do

destination <- "~/Desktop/Covid19_timeseries.json"
download.file('https://pomber.github.io/covid19/timeseries.json', destination)
  •  Tags:  
  • r
  • Related