Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

safeframe should retain class inheritance order when restoring class #56

Open
Bisaloo opened this issue Dec 3, 2024 · 0 comments · May be fixed by #62
Open

safeframe should retain class inheritance order when restoring class #56

Bisaloo opened this issue Dec 3, 2024 · 0 comments · May be fixed by #62

Comments

@Bisaloo
Copy link
Member

Bisaloo commented Dec 3, 2024

Currently, when the safeframe class is stripped and restored, it is also added as the most internal class, but one may want to create a subclass of safeframe (e.g., linelist) and this should remain a safeframe subclass throughout all operations.

library(safeframe)
#> 
#> Attaching package: 'safeframe'
#> The following object is masked from 'package:base':
#> 
#>     labels

x <- make_safeframe(
  cars,
  speed = "Miles per hour"
)
class(x) <- c("linelist", class(x))

class(x)
#> [1] "linelist"   "safeframe"  "data.frame"

y <- x[, 1]
#> Warning: The following labelled variables are lost:
#>  dist - NULL

class(y)
#> [1] "safeframe"  "linelist"   "data.frame"

identical(class(x), class(y))
#> [1] FALSE

Created on 2024-12-03 with reprex v2.1.1

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.4.0 (2024-04-24)
#>  os       Ubuntu 24.04.1 LTS
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language en_US
#>  collate  en_GB.UTF-8
#>  ctype    en_GB.UTF-8
#>  tz       Europe/Paris
#>  date     2024-12-03
#>  pandoc   3.2 @ /usr/lib/rstudio/resources/app/bin/quarto/bin/tools/x86_64/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date (UTC) lib source
#>  backports     1.5.0   2024-05-23 [1] CRAN (R 4.4.0)
#>  checkmate     2.3.2   2024-07-29 [1] CRAN (R 4.4.1)
#>  cli           3.6.3   2024-06-21 [1] CRAN (R 4.4.0)
#>  digest        0.6.37  2024-08-19 [1] CRAN (R 4.4.1)
#>  evaluate      1.0.1   2024-10-10 [1] CRAN (R 4.4.1)
#>  fastmap       1.2.0   2024-05-15 [1] CRAN (R 4.4.0)
#>  fs            1.6.5   2024-10-30 [1] CRAN (R 4.4.0)
#>  glue          1.8.0   2024-09-30 [1] CRAN (R 4.4.1)
#>  htmltools     0.5.8.1 2024-04-04 [1] CRAN (R 4.4.0)
#>  knitr         1.49    2024-11-08 [1] CRAN (R 4.4.0)
#>  lifecycle     1.0.4   2023-11-07 [1] CRAN (R 4.4.0)
#>  reprex        2.1.1   2024-07-06 [1] CRAN (R 4.4.0)
#>  rlang         1.1.4   2024-06-04 [1] CRAN (R 4.4.0)
#>  rmarkdown     2.29    2024-11-04 [1] CRAN (R 4.4.0)
#>  rstudioapi    0.17.1  2024-10-22 [1] CRAN (R 4.4.0)
#>  safeframe   * 0.0.1   2024-11-30 [1] Github (epiverse-trace/safeframe@7bf3f00)
#>  sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.4.0)
#>  withr         3.0.2   2024-10-28 [1] CRAN (R 4.4.0)
#>  xfun          0.49    2024-10-31 [1] CRAN (R 4.4.0)
#>  yaml          2.3.10  2024-07-26 [1] CRAN (R 4.4.1)
#> 
#>  [1] /home/hugo/.local/share/R/x86_64-pc-linux-gnu-library/4.4
#>  [2] /opt/R/4.4.0/lib/R/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant