dimRed
dimRed copied to clipboard
Argument `.keep.org.data` not working
trafficstars
Hi there,
Please see below the repro. The examples are taken from documentation of embed.
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
as.data.frame(
embed(Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width,
iris, "PCA", .keep.org.data = FALSE)
)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'as.data.frame': invalid class "dimRedResult" object: invalid object for slot "org.data" in class "dimRedResult": got class "NULL", should be or extend class "matrix"
as.data.frame(embed(iris[, 1:4], "PCA", .keep.org.data = FALSE))
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'as.data.frame': invalid class "dimRedResult" object: invalid object for slot "org.data" in class "dimRedResult": got class "NULL", should be or extend class "matrix"
Created on 2022-08-28 by the reprex package (v2.0.1)
I can confirm it, thanks for reporting!
FYI: it keeps the original data if you omit .keep.org.data.
in dimRedResults-class, the slot org.data can only be of class matrix, so I cannot just use a NULL. Should getOrgData and getData return a 0-column matrix silently or throw an error or a warning if the original data is not saved?