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

Problems with data frames #45

Open
ivanhigueram opened this issue Jun 29, 2018 · 9 comments
Open

Problems with data frames #45

ivanhigueram opened this issue Jun 29, 2018 · 9 comments

Comments

@ivanhigueram
Copy link

Hello,

I'm trying to use a data.frame as a parts argumento to the waffle function, but I'm getting a object type error. Using your example to reproduce the error the problem persists.

> parts <- data.frame(
+   names = LETTERS[1:4],
+   vals = c(80, 30, 20, 10)
+ )
> 
> waffle(parts, rows = 8)
Error in FUN(X[[i]], ...) : 
  (list) object cannot be coerced to type 'double'

Any idea on what's happening? The only way to get it working is to pass a vector.

@hrbrmstr
Copy link
Owner

are you using the GH version? I just tried it and it works w/o issue.

@ivanhigueram
Copy link
Author

Nope, I install the package from CRAN, not from GH.

@Breza
Copy link
Contributor

Breza commented Jul 13, 2018

Installing the Github version fixed this issue for me

@critmcdonald
Copy link

Unfortunately, installing from Github devtools did not fix this for me. I have version 0.9.1 and I'm getting that same error.

@hrbrmstr
Copy link
Owner

hrbrmstr commented May 8, 2019 via email

@moldach
Copy link

moldach commented May 15, 2019

I second this issue 😭

parts <- data.frame(
    names = LETTERS[1:4],
    vals = c(80, 30, 20, 10)
)
waffle(parts, rows = 8)
Error in FUN(X[[i]], ...) : 
  (list) object cannot be coerced to type 'double'

sessionInfo()
Error: $ operator is invalid for atomic vectors
In addition: Warning message:
In FUN(X[[i]], ...) :
  DESCRIPTION file of package 'waffle' is missing or broken

Usually on my laptop I would delete the package from .libPath() and re-install the dev version from Github; however, I'm working from the work server and don't have sudo.

Given that my RStudio server shows this:

.libPaths()
[1] "/exports/meaney.lab/moldach/R/x86_64-pc-linux-gnu-library/3.5"
[2] "/usr/lib64/R/library"                                         
[3] "/opt/R/3.5.3/lib64/R/library"

Where the top PATH is my personal env and the other two I cannot touch

How can I tell R which PATH I would like to load the Github version of the package (my personal env) in the meantime until I can file an IT request?

@moldach
Copy link

moldach commented May 15, 2019

waffle(parts, rows = 8)
Error in FUN(X[[i]], ...) :
(list) object cannot be coerced to type 'double'

sessionInfo()
Error: $ operator is invalid for atomic vectors
In addition: Warning message:
In FUN(X[[i]], ...) :
DESCRIPTION file of package 'waffle' is missing or broken

Weird a session restart has solved the issue?

Including my sessionInfo() (which actually prints this time?) in-case this helps anyone else:

sessionInfo()
R version 3.5.3 (2019-03-11)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /share/apps/anaconda2/lib/libopenblasp-r0.3.5.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] waffle_0.9.1   ggplot2_3.1.1  usethis_1.5.0  devtools_2.0.2

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.1         RColorBrewer_1.1-2 compiler_3.5.3    
 [4] pillar_1.4.0       plyr_1.8.4         prettyunits_1.0.2 
 [7] remotes_2.0.4      tools_3.5.3        extrafont_0.17    
[10] testthat_2.1.1     digest_0.6.18      pkgbuild_1.0.3    
[13] pkgload_1.0.2      memoise_1.1.0.9000 tibble_2.1.1      
[16] gtable_0.3.0       pkgconfig_2.0.2    rlang_0.3.4       
[19] cli_1.1.0          rstudioapi_0.10    curl_3.3          
[22] Rttf2pt1_1.3.7     gridExtra_2.3      stringr_1.4.0     
[25] withr_2.1.2        dplyr_0.8.0.1      desc_1.2.0        
[28] fs_1.2.7           rprojroot_1.3-2    grid_3.5.3        
[31] tidyselect_0.2.5   glue_1.3.1         R6_2.4.0          
[34] processx_3.3.0     sessioninfo_1.1.1  extrafontdb_1.0   
[37] callr_3.2.0        purrr_0.3.2        magrittr_1.5      
[40] backports_1.1.4    scales_1.0.0       ps_1.3.0          
[43] assertthat_0.2.1   colorspace_1.4-1   labeling_0.3      
[46] stringi_1.4.3      lazyeval_0.2.2     munsell_0.5.0     
[49] crayon_1.3.4  

Oh also since your a very R savvy person if you do know an answer to:

Given that my RStudio server shows this:

.libPaths()
[1] "/exports/meaney.lab/moldach/R/x86_64-pc-linux-gnu-library/3.5"
[2] "/usr/lib64/R/library"                                         
[3] "/opt/R/3.5.3/lib64/R/library"

Where the top PATH is my personal env and the other two I cannot touch

How can I tell R which PATH I would like to load the Github version of the package (my personal env) in the meantime until I can file an IT request?

I'd love to hear it 😊

@matiasandina
Copy link

Same issue here

> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.2 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/atlas/libblas.so.3.10.3
LAPACK: /usr/lib/x86_64-linux-gnu/atlas/liblapack.so.3.10.3

locale:
 [1] LC_CTYPE=en_US.UTF-8          LC_NUMERIC=C                 
 [3] LC_TIME=en_US.UTF-8           LC_COLLATE=en_US.UTF-8       
 [5] LC_MONETARY=en_US.UTF-8       LC_MESSAGES=en_US.UTF-8      
 [7] LC_PAPER=en_US.UTF-8          LC_NAME=en_US.UTF-8          
 [9] LC_ADDRESS=en_US.UTF-8        LC_TELEPHONE=en_US.UTF-8     
[11] LC_MEASUREMENT=en_US.UTF-8    LC_IDENTIFICATION=en_US.UTF-8

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

other attached packages:
[1] waffle_1.0.0         ggforce_0.2.0        stringr_1.3.1       
[4] rChoiceDialogs_1.0.6 rJava_0.9-10         ggplot2_3.1.0       
[7] dplyr_0.8.0.1       

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.1         lattice_0.20-35    prettyunits_1.0.2  ps_1.2.0          
 [5] zoo_1.8-4          assertthat_0.2.0   zeallot_0.1.0      rprojroot_1.3-2   
 [9] digest_0.6.18      utf8_1.1.4         R6_2.3.0           plyr_1.8.4        
[13] backports_1.1.2    pillar_1.4.0       rlang_0.3.4        curl_3.3          
[17] lazyeval_0.2.1     rstudioapi_0.8     extrafontdb_1.0    callr_3.0.0       
[21] desc_1.2.0         labeling_0.3       devtools_2.0.1     extrafont_0.17    
[25] polyclip_1.9-1     munsell_0.5.0      compiler_3.4.4     pkgconfig_2.0.2   
[29] base64enc_0.1-3    pkgbuild_1.0.2     tidyselect_0.2.5   tibble_2.1.1      
[33] gridExtra_2.3      fansi_0.4.0        crayon_1.3.4       withr_2.1.2       
[37] MASS_7.3-49        grid_3.4.4         Rttf2pt1_1.3.7     gtable_0.2.0      
[41] magrittr_1.5       scales_1.0.0       cli_1.1.0          stringi_1.2.4     
[45] farver_1.1.0       reshape2_1.4.3     fs_1.2.6           remotes_2.0.2     
[49] testthat_2.1.1     vctrs_0.1.0        cowplot_0.9.4      RColorBrewer_1.1-2
[53] tools_3.4.4        glue_1.3.0         tweenr_1.0.1       purrr_0.3.2       
[57] processx_3.2.0     pkgload_1.0.2      colorspace_1.3-2   sessioninfo_1.1.0 
[61] memoise_1.1.0      usethis_1.5.0     

@moldach
Copy link

moldach commented Jul 24, 2019

Shout out to Miles McBain for solving this one: https://milesmcbain.xyz/hacking-r-library-paths/

This is how my PATHS look like

.libPaths()
[1] "/exports/meaney.lab/moldach/R/x86_64-pc-linux-gnu-library/3.5"
[2] "/usr/lib64/R/library"                                         
[3] "/opt/R/3.5.3/lib64/R/library"

Now I try and load the package with library(waffle) and check sessionInfo() but I see it's loaded version 0.9.1 from /usr/lib64/R/library

Let's say my IT specialist is away for the day, or that they are worried about updating the package since it could have unintended affects on other packages. So they tell me to run devtools::install_github("hrbrmstr/waffle") to install the package into my local library.

Okay so once that's done I want to detach the old version with detach("package:waffle", unload=TRUE) then use the following function to force R to load the library from my local library:

set_lib_paths <- function(lib_vec) {

  lib_vec <- normalizePath(lib_vec, mustWork = TRUE)

  shim_fun <- .libPaths
  shim_env <- new.env(parent = environment(shim_fun))
  shim_env$.Library <- character()
  shim_env$.Library.site <- character()

  environment(shim_fun) <- shim_env
  shim_fun(lib_vec)

}

set_lib_paths("/exports/meaney.lab/moldach/R/x86_64-pc-linux-gnu-library/3.5")
library(waffle)
sessionInfo()

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

No branches or pull requests

6 participants