A few months ago I had some code that did an awesome job of helping me read in NCDF files and flatten them out to a single tibble. This week, I needed some additional years, so I went back to the same script, but it no longer works. I have no idea what changed.
First I load the libraries
library(tidyverse)
library(tidync)
Then I make a list of files from a folder
files <- list.files(path = "merra_hourly/mandan_merra", pattern = ".nc")
I reset the working directory and then try to use the tidync function on each file. This is where it stops working.
setwd("merra_hourly/mandan_merra")
mandan<-purrr::map(files, tidync)
Error in nc_meta.character(...) : **
** failed to open 'x', value given was: "mandan0001.nc"
But, if it had worked like before, I just need three more lines for my tibble. So close.
names(mandan)<-gsub("\\.nc", "", files)
tidy_mandan<-purrr::map(mandan, ~hyper_tibble(.))%>%
bind_rows(.id = "day")
I hadn't updated the tidync package when I got the error the first time, but I have updated it since and gotten the same error. Also, it was run with the same version of R a few months ago and now (3.4.3), which I haven't updated (but I guess I should). When I try the original script with the original files, I get the same error.
What am I missing?