Problem with glmnet R package [duplicate] - r

I'm using glmnet R package. And before today I had no problems using it. I installed caret two days ago, I had some troubles to install it but I succeeded to do some by re-installing some packages like.
Here is the error message I get :
Error in .fixupDimnames(.Object#Dimnames) :
could not find function "lengths"
I'm using an old version of R, that I can't update right now.
sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=French_France.1252 LC_CTYPE=French_France.1252 LC_MONETARY=French_France.1252
[4] LC_NUMERIC=C LC_TIME=French_France.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] glmnet_2.0-2 foreach_1.4.2 Matrix_1.2-2 caret_6.0-52 ggplot2_0.9.3.1 lattice_0.20-23 ade4_1.6-2
loaded via a namespace (and not attached):
[1] BradleyTerry2_1.0-6 brglm_0.5-9 car_2.0-19 codetools_0.2-11 colorspace_1.2-4 compiler_3.0.2
[7] dichromat_2.0-0 digest_0.6.4 grid_3.0.2 gtable_0.1.2 gtools_3.5.0 iterators_1.0.7
[13] labeling_0.2 lme4_1.1-8 MASS_7.3-29 minqa_1.2.4 munsell_0.4.2 nlme_3.1-111
[19] nloptr_1.0.4 nnet_7.3-7 plyr_1.8 pROC_1.8 proto_0.3-10 RColorBrewer_1.0-5
[25] Rcpp_0.12.0 reshape2_1.2.2 scales_0.2.3 splines_3.0.2 stats4_3.0.2 stringr_0.6.2
[31] tools_3.0.2
The error is obtained after calling :
gg <- glmnet(x=data, y=Y.train, family="binomial", alpha=0, lambda=1)
Y.train is factor, and data a matrix of dummies. But I think that the issue is not a matter of data.
But it is more likely something linked with a package or something like this that I'm missing.
If anybody has a clue, it would be great.

I reinstall Matrix_1.1-1.tar.gz, and it worked.
So, you can try to change your Matrix package.

Related

Error in loading package SASxport: object ‘label<-.data.frame’ is not exported by 'namespace:Hmisc'

I'm trying to read data in the XPT format into R (the format can be found for example in the NHANES data). I found two functions doing this:
library("Hmisc")
sasxport.get("C:/path/file.XPT")
and
library("SASxport")
read.xport("C:/path/file.XPT")
The sasxport.get works, so I'm basically fine, but still inquisitive enough to understand (and solve) the following error: after the installation of the SASxport package, I cannot load it. When I run library("SASxport"), I get the error message:
Error: package or namespace load failed for ‘SASxport’:
object ‘label<-.data.frame’ is not exported by 'namespace:Hmisc'
Adopting this suggestion, I also ran
remove.packages(c("SASxport", "Hmisc"))
install.packages('Hmisc', dependencies = TRUE)
install.packages('SASxport', dependencies = TRUE)
what did not change the error message.
This is my sessionInfo():
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252
[4] LC_NUMERIC=C LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] Hmisc_4.1-1 ggplot2_2.2.1 Formula_1.2-2 survival_2.41-3 lattice_0.20-35
loaded via a namespace (and not attached):
[1] Rcpp_0.12.14 pillar_1.0.1 compiler_3.4.3 RColorBrewer_1.1-2 plyr_1.8.4
[6] base64enc_0.1-3 iterators_1.0.9 tools_3.4.3 rpart_4.1-11 digest_0.6.13
[11] tibble_1.4.1 gtable_0.2.0 htmlTable_1.11.1 checkmate_1.8.5 rlang_0.1.6
[16] icenReg_2.0.7 Matrix_1.2-12 foreach_1.4.4 rstudioapi_0.7 yaml_2.1.16
[21] gridExtra_2.3 coda_0.19-1 stringr_1.2.0 cluster_2.0.6 knitr_1.18
[26] htmlwidgets_0.9 grid_3.4.3 nnet_7.3-12 data.table_1.10.4-3 foreign_0.8-69
[31] latticeExtra_0.6-28 magrittr_1.5 scales_0.5.0 backports_1.1.2 codetools_0.2-15
[36] htmltools_0.3.6 splines_3.4.3 colorspace_1.3-2 stringi_1.1.6 acepack_1.4.1
[41] lazyeval_0.2.1 munsell_0.4.3
The last update of SASxport happend nearly two years ago (2016-03-11). So the Hmisc package it imports might have changed in the meantime. Looking up the Hmisc archive I found the version number on 2016-03-11 to be 3.17-2. So installing this version fixes the problem:
library("devtools")
install_version("Hmisc", version = "3.17-2")
Two reasons speak against using SASxport in this case:
You need to use a old version of a package which might happer your work in later steps.
SASxport needs Hmisc for a task that Hmisc can do already by itself, so SASxport is expendable when reading in XPT files.

R Shinyapp works locally but not on Shinyapp.io server

I am trying to make a shinyapp which let users upload a certain format of file. After uploading the file, the shinyapp will automatically plot some table and charts using dplyr and rCharts.
It works well when I run it locally using “Run App”. However, when I publish to shinyapp.io, I got this error:
path1="": No such file or directory
After searching on the internet, I haven’t found any solution to solve this problem. Could anyone help me on what the possible reason causing this issue?
Here is my code and my sessionInfo().(It's a little bit long and messy)
https://github.com/johnnychiuchiu/Cheetah_ShinyApp/blob/master/server.r
R version 3.2.2 (2015-08-14)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.4 (Yosemite)
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
[7] base
other attached packages:
[1] stringr_1.0.0 dplyr_0.4.2 rCharts_0.4.5 shiny_0.12.2
loaded via a namespace (and not attached):
[1] Rcpp_0.12.1 lattice_0.20-33 assertthat_0.1
[4] digest_0.6.8 mime_0.3 grid_3.2.2
[7] plyr_1.8.3 R6_2.1.0 DBI_0.3.1
[10] xtable_1.7-4 jsonlite_0.9.16 magrittr_1.5
[13] stringi_0.5-5 lazyeval_0.1.10 rstudioapi_0.3.1
[16] whisker_0.3-2 RJSONIO_1.3-0 tools_3.2.2
[19] parallel_3.2.2 httpuv_1.3.3 yaml_2.1.13
[22] rsconnect_0.4.1.4 htmltools_0.2.6
The "h" in "Highcharts" needs to be lowercase, e.g.:
showOutput("h5", "highcharts"),
If that doesn't work: For the deployment, showOutput needs you to detail the path to your rcharts-lilbrary (at least in my case, for whatever reason ^^).
I had a problem which was very similar to yours. Here's my solution:
"ERROR: path[1]="": No such file or directory" when publishing Parallel Coordinates Chart with Shiny

Can't run glmnet() R package : " could not find function "lengths" "

I'm using glmnet R package. And before today I had no problems using it. I installed caret two days ago, I had some troubles to install it but I succeeded to do some by re-installing some packages like.
Here is the error message I get :
Error in .fixupDimnames(.Object#Dimnames) :
could not find function "lengths"
I'm using an old version of R, that I can't update right now.
sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=French_France.1252 LC_CTYPE=French_France.1252 LC_MONETARY=French_France.1252
[4] LC_NUMERIC=C LC_TIME=French_France.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] glmnet_2.0-2 foreach_1.4.2 Matrix_1.2-2 caret_6.0-52 ggplot2_0.9.3.1 lattice_0.20-23 ade4_1.6-2
loaded via a namespace (and not attached):
[1] BradleyTerry2_1.0-6 brglm_0.5-9 car_2.0-19 codetools_0.2-11 colorspace_1.2-4 compiler_3.0.2
[7] dichromat_2.0-0 digest_0.6.4 grid_3.0.2 gtable_0.1.2 gtools_3.5.0 iterators_1.0.7
[13] labeling_0.2 lme4_1.1-8 MASS_7.3-29 minqa_1.2.4 munsell_0.4.2 nlme_3.1-111
[19] nloptr_1.0.4 nnet_7.3-7 plyr_1.8 pROC_1.8 proto_0.3-10 RColorBrewer_1.0-5
[25] Rcpp_0.12.0 reshape2_1.2.2 scales_0.2.3 splines_3.0.2 stats4_3.0.2 stringr_0.6.2
[31] tools_3.0.2
The error is obtained after calling :
gg <- glmnet(x=data, y=Y.train, family="binomial", alpha=0, lambda=1)
Y.train is factor, and data a matrix of dummies. But I think that the issue is not a matter of data.
But it is more likely something linked with a package or something like this that I'm missing.
If anybody has a clue, it would be great.
I reinstall Matrix_1.1-1.tar.gz, and it worked.
So, you can try to change your Matrix package.

Lazyeval over-writing dplyr?

Not quite understanding what "lazyeval" is, I was trying to install and run the package to use dplyr within a function.
When I ran
library(lazyeval)
I got the error message:
Error in library(lazyeval) : there is no package called 'lazyeval'
even after successfully installing.
Now, though, when I try to run any standard dplyr script, I get the following error message:
Error in loadNamespace(name) : there is no package called 'lazyeval'
It's as if the lazyeval has over-written dplyr, but I can't actually use lazyeval.
Has anyone run into this issue? If so, how did you resolve?
Some info:
sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] grid splines stats graphics grDevices utils datasets
[8] methods base
other attached packages:
[1] scales_0.2.4 gridExtra_0.9.1 ggplot2_1.0.0 forecast_5.4
[5] timeDate_3010.98 reshape2_1.4 xts_0.9-7 zoo_1.7-11
[9] lubridate_1.3.3 dplyr_0.4.1 plyr_1.8.1
loaded via a namespace (and not attached):
[1] assertthat_0.1 colorspace_1.2-4 DBI_0.3.1 digest_0.6.4
[5] fracdiff_1.4-2 gtable_0.1.2 lattice_0.20-29 magrittr_1.0.1
[9] MASS_7.3-35 memoise_0.2.1 munsell_0.4.2 nnet_7.3-8
[13] parallel_3.1.2 proto_0.3-10 quadprog_1.5-5 Rcpp_0.11.1
[17] stringr_0.6.2 tools_3.1.2 tseries_0.10-32
When I run .libPaths(), I get two directories:
[1] "C:/Users/MTULLA/Documents/R/win-library/3.1"
[2] "C:/Program Files/R/R-3.1.2/library"
In the first, I can find both dplyr and lazyeval, both with .dll files. In the second, I can't find either
I also got this message when running the lesson 1 of Getting and Cleaning Data on Swirl.
Package ‘dplyr’ loaded correctly!
Error in loadNamespace(name) : there is no package called ‘lazyeval’
Reinstalling packages also didn't work
It was solved by updating my R version using the {installr} package
It can be resolved by installing the package with all the dependencies, using:
install.packages("dplyr", dependencies = TRUE)
It will install others like lazyeval, knitr etc. Worked for me to solve the
Error in loadNamespace(name): there is no package called ‘lazyeval’ issue.

Code chunk using repmis::dropboxData works in one Rstudio project but not another

I have two R projects associated with github repositories.
I have been using the repmis function source_DropboxData to download a file, then tbl_df in dplyr
In both projects the code is:
require(repmis)
require(plyr)
require(dplyr)
require(tidyr)
require(ggplot2)
# simd vars
simd_2009 <- source_DropboxData(
file="simd_2009.csv",
key="ghiu8n9db6rch9y"
) %>% tbl_df()
In one of the projects this crashes RStudio; in the other it does not.
sessionInfo() on the project that works:
> sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252 LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] knitr_1.9 ggplot2_1.0.0 tidyr_0.2.0 dplyr_0.4.1 plyr_1.8.1 repmis_0.3.3
loaded via a namespace (and not attached):
[1] assertthat_0.1 colorspace_1.2-4 DBI_0.3.1 digest_0.6.8 evaluate_0.5.5 formatR_1.0 grid_3.1.2
[8] gtable_0.1.2 httr_0.6.1 magrittr_1.5 MASS_7.3-35 munsell_0.4.2 packrat_0.4.2-1 parallel_3.1.2
[15] proto_0.3-10 R.cache_0.10.0 R.methodsS3_1.6.1 R.oo_1.18.0 R.utils_1.34.0 Rcpp_0.11.3 reshape2_1.4.1
[22] rJava_0.9-6 scales_0.2.4 stringr_0.6.2 tools_3.1.2 xlsx_0.5.7 xlsxjars_0.6.1
sessionInfo() on the project that crashes:
R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252 LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggplot2_1.0.0 tidyr_0.2.0 dplyr_0.4.1 plyr_1.8.1 repmis_0.4
loaded via a namespace (and not attached):
[1] assertthat_0.1 chron_2.3-45 colorspace_1.2-4 data.table_1.9.4 DBI_0.3.1 digest_0.6.4 grid_3.1.2
[8] gtable_0.1.2 httr_0.6.1 magrittr_1.5 MASS_7.3-35 munsell_0.4.2 packrat_0.4.2-1 parallel_3.1.2
[15] proto_0.3-10 R.cache_0.10.0 R.methodsS3_1.6.1 R.oo_1.18.0 R.utils_1.34.0 Rcpp_0.11.3 reshape2_1.4
[22] rJava_0.9-6 scales_0.2.4 stringr_0.6.2 tools_3.1.2 xlsx_0.5.7 xlsxjars_0.6.1
What is likely to be the cause of the difference and how could I investigate further?
Update
Clearly the main difference is that the version that works uses repmis_0.3.3 and the version that doesn't uses repmis_0.4. I'm going to look at using repmis to downgrade itself!
The downgrade did not seem to work - "installation had non-zero exit status"
n.b. I'm also using packrat on both projects
I've now tried repmis 0.4 outside of either package, it works. However plyr and dplyr are not installed.
It works with plyr installed...
In this case, packrat was causing the issue. Removing it solved the problem!

Resources