Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new meteo_nearby_stations() error #286

Closed
ghaines3 opened this issue Nov 23, 2018 · 6 comments
Closed

new meteo_nearby_stations() error #286

ghaines3 opened this issue Nov 23, 2018 · 6 comments
Labels
Milestone

Comments

@ghaines3
Copy link

Hi,
Sorry for all the questions recently, but I have been using this code in the meteo_nearby_stations() function for the past few weeks, and today is the first time it gave me this error. The only new part I put in is the station_data (all.stations is the output of ghcnd_stations()), but I was getting the error before I added it. I've played around with this quite a bit, but it always gives me the same error. Any idea what is going wrong here?

Thanks!

> head(site1)
   sample1.longitude sample1.latitude  id
1           175.2833        -37.78333  98
13          176.0694        -38.68750 100
24          175.6117        -40.35500  99
34          176.8333        -39.65000 101
43          172.6203        -43.53000  91
51          173.7997        -35.40750  93

> clim.dat1<-meteo_nearby_stations(lat_lon_df = site1, lat_colname = "sample1.latitude",
+                       lon_colname = "sample1.longitude", station_data = all.stations,
+                       var = c("PRCP","TMIN","TMAX","TAVG"), year_min = 2008, 
+                       year_max = 2017, limit = 3)
Error in `$<-.data.frame`(`*tmp*`, "latitude", value = numeric(0)) : 
  replacement has 0 rows, data has 140
Session Info
> sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.6

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] memisc_0.99.14.12 MASS_7.3-48       lattice_0.20-35   data.table_1.11.8
[5] plyr_1.8.4        rnoaa_0.7.1.9810  geosphere_1.5-7   rlist_0.4.6.1    
[9] tidyr_0.8.2      

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.0         lubridate_1.7.4    utf8_1.1.4        
 [4] assertthat_0.2.0   digest_0.6.18      mime_0.6          
 [7] R6_2.3.0           repr_0.17          MatrixModels_0.4-1
[10] httr_1.3.1         ggplot2_3.1.0      pillar_1.3.0      
[13] rlang_0.3.0.1      lazyeval_0.2.1     curl_3.2          
[16] rstudioapi_0.8     minqa_1.2.4        SparseM_1.77      
[19] car_2.1-6          nloptr_1.0.4       Matrix_1.2-12     
[22] splines_3.4.3      lme4_1.1-15        stringr_1.3.1     
[25] munsell_0.5.0      compiler_3.4.3     pkgconfig_2.0.2   
[28] base64enc_0.1-3    mgcv_1.8-23        htmltools_0.3.6   
[31] nnet_7.3-12        tidyselect_0.2.5   tibble_1.4.2      
[34] gridExtra_2.3      httpcode_0.2.0     XML_3.98-1.16     
[37] fansi_0.4.0        crayon_1.3.4       dplyr_0.7.8       
[40] hoardr_0.5.0       rappdirs_0.3.1     crul_0.6.0        
[43] grid_3.4.3         nlme_3.1-131       jsonlite_1.5      
[46] gtable_0.2.0       magrittr_1.5       scales_1.0.0      
[49] cli_1.0.1          stringi_1.2.4      bindrcpp_0.2.2    
[52] sp_1.3-1           xml2_1.2.0         tools_3.4.3       
[55] glue_1.3.0         purrr_0.2.5        pbkrtest_0.4-7    
[58] parallel_3.4.3     colorspace_1.3-2   bindr_0.1.1       
[61] quantreg_5.34   
@sckott
Copy link
Contributor

sckott commented Nov 26, 2018

FULLY REPRODUCIBLE example please. what is site1 ?

@ghaines3
Copy link
Author

Sorry, site1 is a dataframe of 3 columns for each site that I am requesting nearby stations for: the longitude, latitude, and id number of each site.

> sample1.longitude <- c(-1.310000,-106.284000,-108.205000,-116.244000)
> sample1.latitude <- c(51.75000,33.42500,33.03500,41.25000)
> id <-c(1,2,3,4)
> site1<-data.frame(sample1.longitude,sample1.latitude,id)
> site1
  sample1.longitude sample1.latitude id
1            -1.310           51.750  1
2          -106.284           33.425  2
3          -108.205           33.035  3
4          -116.244           41.250  4
> clim.dat1<-meteo_nearby_stations(lat_lon_df = site1, lat_colname = "sample1.latitude",
+                                  lon_colname = "sample1.longitude", station_data = all.stations,
+                                  var = c("PRCP","TMIN","TMAX","TAVG"), year_min = 2008, 
+                                  year_max = 2017, limit = 3)
Error in `$<-.data.frame`(`*tmp*`, "latitude", value = numeric(0)) : 
  replacement has 0 rows, data has 4

@sckott
Copy link
Contributor

sckott commented Nov 29, 2018

thanks, will have a look

@sckott
Copy link
Contributor

sckott commented Nov 29, 2018

turns out the code requires columns exactly as latitude and longitude - fixin now

@sckott sckott added the bug label Nov 29, 2018
@sckott sckott added this to the v0.8 milestone Nov 29, 2018
@sckott sckott closed this as completed in 8122766 Nov 29, 2018
@sckott
Copy link
Contributor

sckott commented Nov 29, 2018

@ghaines3 try again afer reinstalling

@ghaines3
Copy link
Author

That did it! Thanks very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants