I am trying to open a shapefile (or the directory of the shapefile) in the same directory as my R file. I open it the following way:
x<-c(farm,field,"ec",2017) #farm and field are variables that hold strings file<-paste(x, collapse="_") #add underscore between each word so it picks up the filename ec <- readOGR(".", file) #read the file
When I try to run the file with Rscript, I get the following error:
Cannot open data source Calls: readOGR -> suppressMessages -> withCallingHandlers -> ogrInfo Execution halted
Even when I use 'read_sf' I still get a "cannot open file" error message and the code stops. How do I fix this?
EDIT: so the path to my shapefile folder(the directory that holds the .shp) "farm_field_ec_2017" is in the directory
my R script is also in this same path. I still cannot figure out my problem.