Error while using as.yearmon


#1

I am having an issue when I run the same piece of code on the different machines with same version of R and updated all packages to the latest version.

ab$Month_considered = as.yearmon(ab$Month_considered, "%b-%y")

This above uses zoo. This works fine on one machine but gives me NA for Month_considered on another. I know this isnt a reproducible example but what else can I be looking into .


#2

The only thing I could suggest is really validating that the R versions, package versions, and other locale-related things really are the same on these different machines. Try checking the output of sessionInfo() and see if anything does differ between the machines.


#3

In addition to @kevinushey’s good suggestions, maybe verify that you’re running in a new session and that none of these machines are loading anything from an .Rdata file on startup? In RStudio, make sure “Restore .RData into workspace at startup” is turned off in Global Options and in Project Options, if you’re using a Project.

Maybe also check that there aren’t any commands hiding in a startup file that could be altering things?

Finally (or maybe initially!), if you examine ab$Month_considered directly, does it look right on both machines? What code is creating it, and can you verify that that code is running successfully?


#4

I have attached the sessioninfo() for both the machines. The first one works and the second one which doesnt. @jcblum I did uncheck the global and project options. The df ab is created the same way on both machines and they seem to be similar when I look for its class usingsapply(ab,class)

#####WORKING
R version 3.5.0 (2018-04-23)
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.5/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 
[6] methods   base     

other attached packages:
 [1] bindrcpp_0.2.2     data.table_1.11.4  dygraphs_1.1.1.6  
 [4] forcats_0.3.0      stringr_1.3.1      purrr_0.2.5       
 [7] readr_1.1.1        tibble_1.4.2       tidyverse_1.2.1   
[10] plyr_1.8.4         zoo_1.8-3          tidyr_0.8.1       
[13] plotly_4.8.0       ggplot2_3.0.0.9000 dplyr_0.7.6       

loaded via a namespace (and not attached):
 [1] tidyselect_0.2.4  reshape2_1.4.3    haven_1.1.1      
 [4] lattice_0.20-35   colorspace_1.3-2  htmltools_0.3.6  
 [7] viridisLite_0.3.0 yaml_2.2.0        rlang_0.2.2      
[10] pillar_1.3.0      foreign_0.8-70    glue_1.3.0       
[13] withr_2.1.2       modelr_0.1.2      readxl_1.1.0     
[16] bindr_0.1.1       munsell_0.5.0     gtable_0.2.0     
[19] cellranger_1.1.0  rvest_0.3.2       htmlwidgets_1.2  
[22] psych_1.8.4       parallel_3.5.0    broom_0.4.4      
[25] Rcpp_0.12.18      scales_1.0.0      jsonlite_1.5     
[28] mnormt_1.5-5      hms_0.4.2         digest_0.6.16    
[31] stringi_1.2.4     grid_3.5.0        cli_1.0.0        
[34] tools_3.5.0       magrittr_1.5      lazyeval_0.2.1   
[37] crayon_1.3.4      pkgconfig_2.0.2   xml2_1.2.0       
[40] lubridate_1.7.4   assertthat_0.2.0  httr_1.3.1       
[43] rstudioapi_0.7    R6_2.2.2          nlme_3.1-137     
[46] compiler_3.5.0   
> 
#####NOT WORKING
R version 3.5.0 (2018-04-23)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
 
Matrix products: default
 
locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252  
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252   
 
attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base    
 
other attached packages:
[1] bindrcpp_0.2.2    data.table_1.11.4 dygraphs_1.1.1.6  forcats_0.3.0     stringr_1.3.1   
 [6] purrr_0.2.5       readr_1.1.1       tibble_1.4.2      tidyverse_1.2.1   plyr_1.8.4      
[11] zoo_1.8-3         tidyr_0.8.1       plotly_4.8.0      ggplot2_3.0.0     dplyr_0.7.6     
 
loaded via a namespace (and not attached):
[1] Rcpp_0.12.18      cellranger_1.1.0  pillar_1.3.0      compiler_3.5.0    bindr_0.1.1     
 [6] tools_3.5.0       digest_0.6.16     packrat_0.4.9-3   lubridate_1.7.4   nlme_3.1-137    
[11] jsonlite_1.5      gtable_0.2.0      viridisLite_0.3.0 lattice_0.20-35   pkgconfig_2.0.2 
[16] rlang_0.2.2       cli_1.0.0         rstudioapi_0.7    yaml_2.2.0        haven_1.1.2     
[21] xml2_1.2.0        withr_2.1.2       httr_1.3.1        hms_0.4.2         htmlwidgets_1.2 
[26] grid_3.5.0        tidyselect_0.2.4  glue_1.3.0        R6_2.2.2          readxl_1.1.0    
[31] modelr_0.1.2      magrittr_1.5      backports_1.1.2   scales_1.0.0      htmltools_0.3.6 
[36] rvest_0.3.2       assertthat_0.2.0  colorspace_1.3-2  stringi_1.2.4     lazyeval_0.2.1  
[41] munsell_0.5.0     broom_0.5.0       crayon_1.3.4