In the loop below, I am trying to create names of rasters associated with each month (e.g. 1-12) of files located in the project file directory in Cloud. There are 12 rasters in the directory.
for (m in 1:12){ #start month cycle
if (m<10){ #conditional to build month to character
mnchar<-paste("0",m,sep="") #add a 0 to months below October
} else { #conditional for months larger than October
mnchar<-toString(m) #months from October to December convert directly to character
} #end of conditional to write month as character
# Generates name of monthly rasters
crasnam<-paste("PRISM_ppt_30yr_normal_4kmM2_",mnchar,"_bil/PRISM_ppt_30yr_normal_4kmM2_",mnchar,"_bil.bil",sep="")
cras<-raster(crasnam) #open monthly raster
pbgmn[,m]<-extract(cras,geocoords) #get monthly values by grid
pavgmn[m,1]<-mean(pbgmn[,m]) #calculate average basin precipitation by month
} #end of month cycle
I am able to run the loop successfully in R Studio but not in Cloud. I suspect I am missing something obvious in the transition from Studio to Cloud. A link to the project is here:
https://rstudio.cloud/spaces/65621/project/1267157
I get the error:
Error in .local(.Object, ...) :
Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer", :
Cannot create a RasterLayer object from this file. (file does not exist)
thanks,
nico