Hi there,
I am relatively new to using R . I am trying to run the below code to download JSON Data from the url:
install.packages('tidyverse')
library(tidyverse)
weather_url <- 'https://api.weather.gov/stations/KBHB/observations/latest'
res <- tryCatch({
fromJSON(weather_url)
}, error = function(e) {
stop('failed to fetch json from url')
})
It allows me to run the weather URL, but when I try to run the tryCatch function, it gives the below error:
Error in value[[3L]](cond) : failed to fetch json from url
I am also receiving this message when running the tidyverse library:
ββ Attaching core tidyverse packages ββββββββββββββββββββββββββββ tidyverse 2.0.0 ββ
β dplyr 1.1.0 β readr 2.1.4
β forcats 1.0.0 β stringr 1.5.0
β ggplot2 3.4.1 β tibble 3.1.8
β lubridate 1.9.2 β tidyr 1.3.0
β purrr 1.0.1
ββ Conflicts ββββββββββββββββββββββββββββββββββββββββββββββ tidyverse_conflicts() ββ
β dplyr::filter() masks stats::filter()
β dplyr::lag() masks stats::lag()
βΉ Use the conflicted package to force all conflicts to become errors
Warning message:
package βtidyverseβ was built under R version 4.2.3
I'm unsure if the problems with tidyverse package are causing the problems with downloading the data from the URL,
Could someone advise me on what to do?