OHI-Science / ohiprep

Ocean Health Index data layer preparation
11 stars 9 forks source link

transportability of code #86

Open kellijohnson-NOAA opened 7 years ago

kellijohnson-NOAA commented 7 years ago

Minor issue I am dealing with when trying to recreate the pressure layers from raw data. I first download the data from the original sources (thank you very much for providing links to those). Then, I changed the working directories in your code to my local machine. Subsequently, all calls using substr do not work because my working directory, which influences the full file path, is different. I have changed the code on my local machine to use gsub("\\.[a-z]{3}", "", sapply(strsplit(x, "-|_"), tail, 1)), which will work for some of the uses of substr to pull out the year.

jamiecmontgomery commented 7 years ago

Thanks @kellijohnson for pointing that out. It's true I've hardcoded most of those substr() functions which would throw errors on other machines. As I update the code I'll make sure to change those and thanks for sharing your fix.

kellijohnson-NOAA commented 7 years ago

No problem. I also came across an issue with stack because of the order in which I loaded packages, so raster::stack works better for me and may lead to increased robustness for others as well.