gdkrmr / dimRed

A Framework for Dimensionality Reduction in R
https://www.guido-kraemer.com/software/dimred/
GNU General Public License v3.0
73 stars 15 forks source link

PCA_L1 fails for ndim=1 #39

Closed khughitt closed 5 years ago

khughitt commented 5 years ago

The PCA_L1 method appears not to work when ndim is set to 1 (... last one for now ;))

To reproduce:

library(dimRed)
## Loading required package: DRR

## Loading required package: kernlab

## Loading required package: CVST

## Loading required package: Matrix

## 
## Attaching package: 'dimRed'

## The following object is masked from 'package:stats':
## 
##     embed

## The following object is masked from 'package:base':
## 
##     as.data.frame
set.seed(1)

embed(matrix(rnorm(1E5), 100), 'PCA_L1', ndim = 1)
## Error in dimnames(rot) <- list(orgnames, newnames): 'dimnames' applied to non-array

System Information:

sessionInfo()
## R version 3.5.2 (2018-12-20)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Arch Linux
## 
## Matrix products: default
## BLAS: /usr/lib/libblas.so.3.8.0
## LAPACK: /usr/lib/liblapack.so.3.8.0
## 
## 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   base     
## 
## other attached packages:
## [1] dimRed_0.2.2   DRR_0.0.3      CVST_0.2-2     Matrix_1.2-15 
## [5] kernlab_0.9-27 colorout_1.2-0
## 
## loaded via a namespace (and not attached):
##  [1] Rcpp_1.0.0         lattice_0.20-38    digest_0.6.18     
##  [4] grid_3.5.2         magrittr_1.5       evaluate_0.12     
##  [7] stringi_1.2.4      pcaL1_1.5.2        rmarkdown_1.11    
## [10] tools_3.5.2        stringr_1.3.1      xfun_0.4          
## [13] yaml_2.2.0         compiler_3.5.2     BiocManager_1.30.4
## [16] htmltools_0.3.6    knitr_1.21
gdkrmr commented 5 years ago

TODO: rotation[, 1:ndim, drop = FALSE]