matloff / polyreg

180 stars 26 forks source link

example(xvalPoly) throws error #13

Open dushoff opened 5 years ago

dushoff commented 5 years ago

I have been trying to run (working) code from a colleague on two different ubuntu machines. I can't get their code to run, and I can't even get the xvalPoly example to run.

Here is the unexpected error, followed by the complete R session in which it was produced (with sessionInfo). I get similar results from another machine. I'm not aware of anything weird I've done.


example(xvalPoly)

xvlPly> y <- mtcars[,1]

xvlPly> data <- cbind(mtcars[,-1], y) # make y column the last column

xvlPly> pf1 <- xvalPoly(data,2,2,"lm",0.8,FALSE) Error in polyFit(training, i, m, use, pcaMethod, pcaLocation, pcaPortion, : pcaMethod should be either NULL, prcomp, or RSpectra


R version 3.5.1 (2018-07-02) -- "Feather Spray" Copyright (C) 2018 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R.

library(polyreg) Loading required package: regtools Loading required package: FNN Loading required package: mvtnorm Loading required package: dummies dummies-1.5.6 provided by Decision Patterns

Loading required package: car Loading required package: carData

packageVersion("polyreg") [1] ‘0.2’ example(xvalPoly)

xvlPly> y <- mtcars[,1]

xvlPly> data <- cbind(mtcars[,-1], y) # make y column the last column

xvlPly> pf1 <- xvalPoly(data,2,2,"lm",0.8,FALSE) Error in polyFit(training, i, m, use, pcaMethod, pcaLocation, pcaPortion, : pcaMethod should be either NULL, prcomp, or RSpectra

sessionInfo() R version 3.5.1 (2018-07-02) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 18.04.1 LTS

Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3 LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so

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

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

other attached packages: [1] polyreg_0.2 regtools_1.0.1 car_3.0-2 carData_3.0-1 dummies_1.5.6 [6] mvtnorm_1.0-8 FNN_1.1.2.1

loaded via a namespace (and not attached): [1] Rcpp_1.0.0 rio_0.5.10 crayon_1.3.4 cellranger_1.1.0 [5] magrittr_1.5 zip_1.0.0 pillar_1.3.0 rlang_0.2.2 [9] readxl_1.1.0 curl_3.2 data.table_1.11.4 openxlsx_4.1.0 [13] tools_3.5.1 forcats_0.3.0 foreign_0.8-71 hms_0.4.2 [17] abind_1.4-5 compiler_3.5.1 pkgconfig_2.0.2 haven_1.1.2 [21] tibble_1.4.2

rdrr1990 commented 5 years ago

It would appear that the example no longer reflected the order of the inputs. Here are similar examples that will run:

y <- mtcars[,1]
data <- cbind(mtcars[,-1], y)
xvalPoly(data,2,2,"lm") # not using pca
xvalPoly(data,2,2,"lm", "prcomp", 0.8) # using pca

I just added the above to the docs so if you re-install, the example should run. Thanks for flagging this!

lorenzwalthert commented 5 years ago

Reference: adding unit tests (https://github.com/matloff/polyreg/issues/11#issuecomment-423836051). Travis would flag errors in examples automatically for you.