1

I am trying the first example with the R package mlr, which can be found here. But I get the following error message:

> lrn = makeLearner("classif.lda") 
Error in substr(packs, 1L + (force.load | force.attach), nchar(packs)) : 
4 arguments passed to .Internal(nchar) which requires 3

The session info gives the following output:

> sessionInfo()
R version 3.2.0 (2015-04-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 8 x64 (build 9200)

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252   
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C                   
[5] LC_TIME=German_Germany.1252    

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

other attached packages:
[1] mlr_2.8          ParamHelpers_1.7 ggplot2_1.0.1    BBmisc_1.9      

loaded via a namespace (and not attached):
 [1] Rcpp_0.11.5      magrittr_1.5     splines_3.2.0    MASS_7.3-40     
 [5] munsell_0.4.2    xtable_1.8-0     colorspace_1.2-6 R6_2.0.1        
 [9] dplyr_0.4.1      stringr_1.0.0    plyr_1.8.2       tools_3.2.0     
[13] parallel_3.2.0   grid_3.2.0       checkmate_1.7.4  gtable_0.1.2    
[17] DBI_0.3.1        ggvis_0.4.2      htmltools_0.2.6  survival_2.38-1 
[21] assertthat_0.1   leaflet_1.0.0    digest_0.6.8     shiny_0.12.2    
[25] reshape2_1.4.1   htmlwidgets_0.5  mime_0.4         parallelMap_1.3 
[29] stringi_0.4-1    scales_0.3.0     backports_1.0.2  httpuv_1.3.3    
[33] proto_0.3-10    

Here is the output of the traceback():

> lrn = makeLearner("classif.lda")
Error in substr(packs, 1L + (force.load | force.attach), nchar(packs)) : 
  4 arguments passed to .Internal(nchar) which requires 3
> traceback()
8: substr(packs, 1L + (force.load | force.attach), nchar(packs))
7: requirePackages(package, why = paste("learner", id), default.method = "load")
6: makeRLearnerInternal(cl, "classif", package, par.set, par.vals, 
       properties, name, short.name, note)
5: addClasses(makeRLearnerInternal(cl, "classif", package, par.set, 
       par.vals, properties, name, short.name, note), c(cl, "RLearnerClassif"))
4: makeRLearnerClassif(cl = "classif.lda", package = "MASS", par.set = makeParamSet(makeDiscreteLearnerParam(id = "method", 
       default = "moment", values = c("moment", "mle", "mve", "t")), 
       makeNumericLearnerParam(id = "nu", lower = 2, requires = quote(method == 
           "t")), makeNumericLearnerParam(id = "tol", default = 1e-04, 
           lower = 0), makeDiscreteLearnerParam(id = "predict.method", 
           values = c("plug-in", "predictive", "debiased"), default = "plug-in", 
           when = "predict"), makeLogicalLearnerParam(id = "CV", 
           default = FALSE, tunable = FALSE)), properties = c("twoclass", 
       "multiclass", "numerics", "factors", "prob"), name = "Linear Discriminant Analysis", 
       short.name = "lda", note = "Learner parameter `predict.method` maps to `method` in `predict.lda`.")
3: (function () 
   {
       makeRLearnerClassif(cl = "classif.lda", package = "MASS", 
           par.set = makeParamSet(makeDiscreteLearnerParam(id = "method", 
               default = "moment", values = c("moment", "mle", "mve", 
                   "t")), makeNumericLearnerParam(id = "nu", lower = 2, 
               requires = quote(method == "t")), makeNumericLearnerParam(id = "tol", 
               default = 1e-04, lower = 0), makeDiscreteLearnerParam(id = "predict.method", 
               values = c("plug-in", "predictive", "debiased"), 
               default = "plug-in", when = "predict"), makeLogicalLearnerParam(id = "CV", 
               default = FALSE, tunable = FALSE)), properties = c("twoclass", 
               "multiclass", "numerics", "factors", "prob"), name = "Linear Discriminant Analysis", 
           short.name = "lda", note = "Learner parameter `predict.method` maps to `method` in `predict.lda`.")
   })()
2: do.call(constructor, list())
1: makeLearner("classif.lda")

Any idea why this error occurs (I am using R version 3.2.0) ?

ee2Dev
  • 1,938
  • 20
  • 29
  • Use `sessionInfo()` to give the version of the `mlr` package you are using as well. I didn't have a problem running that code in my R. – MrFlick May 05 '16 at 22:05
  • @MrFlick: I just added sessionInfo() to my question – ee2Dev May 05 '16 at 22:24
  • I tried with `R 3.2.2` on a Mac. Same package version. Did you try after a fresh R restart? What does the `traceback()` say after the error? – MrFlick May 05 '16 at 22:32
  • @MrFlick: just added the traceback output. Should I upgrade to R.3.2.2 ? – ee2Dev May 05 '16 at 22:36
  • also runs okay on ubuntu Rv3.3, mlr v2.8 – user20650 May 05 '16 at 23:26
  • It sounds like your R installation and/or package registry is corrupted. Have you tried with a fresh installation of R? – Lars Kotthoff May 06 '16 at 08:40
  • What happens, when you load `library(MASS)` manually before? – jakob-r May 06 '16 at 10:28
  • @Lars Kotthoff I am confused.. loading library(MASS) before also didn't change anything. So I downloaded a fresh R version (3.3.0 - 64-bit). However, I fail now even to install the package (mlr). I get the error message: `Package which is only available in source form, and may need compilation of C/C++/Fortran: ‘mlr’` [I unsucessfully tried this answer to solve this](http://stackoverflow.com/questions/31249980/error-in-r-package-which-is-only-available-in-source-form-and-may-need-compil) – ee2Dev May 06 '16 at 20:47
  • Could my error messages be related to access rights? When I quit a R Studio session, it fails to save the workspace image due to access rights - I don't have admin access rights by default. – ee2Dev May 06 '16 at 20:58
  • Yeah, sounds like this is an issue with your R installation and not the package. – Lars Kotthoff May 06 '16 at 21:19
  • @LarsKotthoff thanks for all the quick replies so far. I just logged in as admin and got the error message which I posted in the question :( – ee2Dev May 06 '16 at 21:25
  • Well, can you install any other packages? How did you install R? – Lars Kotthoff May 06 '16 at 21:26
  • I tried now directly from the R console (not R Studio), which I downloaded and extracted from CRAN (version 3.3.0). I can install other packages ("knitr" or "ggvis"). But when I type install.packages("mlr"), I get the message mentioned above: `Package which is only available in source form, and may need compilation of C/C++/Fortran: ‘mlr’` – ee2Dev May 07 '16 at 14:25
  • Ok, in that case you need to install a compiler. See https://www.biostat.wisc.edu/~kbroman/Rintro/Rwinpack.html – Lars Kotthoff May 08 '16 at 21:59
  • You need [Rtools](https://cran.r-project.org/bin/windows/Rtools/). – catastrophic-failure Aug 09 '16 at 14:55

0 Answers0