ropensci/prism

ls_prism_data() function error

aramcharan opened this issue · 8 comments

Testing out tutorial in Rstudio and getting the following error for ls_prism_data()

Error in if (type == "tmin") { : missing value where TRUE/FALSE needed

@aramcharan Would you please post the code or steps you took that results in the error?

If I follow the code in the ls_prism_data() example, I do not get an error. The following did produce the correct output. Note that I added the first two lines so that I knew where the files would be saved to.

dir.create("~/prism")
options(prism.path = "~/prism/")

# from the ls_prism_data() help page
get_prism_dailys(type="tmean", minDate = "2013-06-01", maxDate = "2013-06-14", keepZip=FALSE)
ls_prism_data()

Here is the code I ran in Rstudio

library(devtools) #needed to download prism from github
library(reshape2) ##melting dataframes
library(dplyr) #data wrangling
library(raster) ##working with raster data
library(sp) ##manipulationg spatial data
library(prism) ##prism data access

#Pull 30 year precipitation normals for July at a 4km grid resolution
options(prism.path = "PATH_TO_DIRECTORY_TO_STORE_DOWNLOADED_DATA")
get_prism_normals(type = 'tmean', resolution = '4km', mon = 12, keepZip = TRUE)

ls_prism_data(name=TRUE) # not working

The version of R I'm on is as follows:
platform x86_64-apple-darwin15.6.0
arch x86_64
os darwin15.6.0
system x86_64, darwin15.6.0
status
major 3
minor 5.1
year 2018
month 07
day 02
svn rev 74947
language R
version.string R version 3.5.1 (2018-07-02)
nickname Feather Spray

@aramcharan
Hmm. I'm unable to recreate an error. Can you use reprex::reprex() around your code to provide it and the output. My results are below:

library(prism)
dir.create("~/prism")
options(prism.path = "~/prism")

get_prism_normals(type = 'tmean', resolution = '4km', mon = 12, keepZip = TRUE)
#> 
  |                                                                       
  |                                                                 |   0%
  |                                                                       
  |=================================================================| 100%
ls_prism_data(name=TRUE)
#>                                  files
#> 1 PRISM_tmean_30yr_normal_4kmM2_12_bil
#>                                              product_name
#> 1 Dec 30-year normals - 4km resolution - Mean temperature

Created on 2019-07-31 by the reprex package (v0.3.0)

ls_prism_data()
#> Error in ls_prism_data(): could not find function "ls_prism_data"

@aramcharan That doesn't match your original issue. That error indicates that you have not loaded prism. Try copying and pasting the following:

library(reprex)

reprex({
  library(prism)
  dir.create("~/prism")
  options(prism.path = "~/prism")

  get_prism_normals(type = 'tmean', resolution = '4km', mon = 12, keepZip = TRUE)
  ls_prism_data(name=TRUE)
})

The output is automatically saved to the clipboard so you can paste everything here.

I used your code to recreate the error and i foudn that when I changed the options command to the full directory name, the download worked and I was able to use the ls_prism_data() function.

Awesome, glad to know it worked!

I'll make sure that get_prism_*() functions and ls_prism_data() check and make sure the prism.path is a valid path. That might help catch this earlier and faster.

thanks for your help on this!