atorus-research / xportr

Tools to build CDISC compliant data sets and check for CDISC compliance.

Home Page:https://atorus-research.github.io/xportr/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong message `All variables in specification file are in dataset`

ynsec37 opened this issue · comments

Dear developer,

When I change the input ADSL that contains only one variable STUDYID, the message All variables in specification file are in dataset still be output.

I am not sure I understand right for this message, it will mean that we have all necessary variables defined in the ADSL variable metadata specification and only be output when the input data frame have these variables

Reproducible Example

library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(xportr)

data("adsl_xportr")
ADSL <- adsl_xportr

spec_path <- system.file(file.path("specs", "ADaM_spec.xlsx"), package = "xportr")

var_spec <- readxl::read_xlsx(spec_path, sheet = "Variables") %>%
  dplyr::rename(type = "Data Type") %>%
  dplyr::rename_with(tolower)
dataset_spec <- readxl::read_xlsx(spec_path, sheet = "Datasets") %>%
  dplyr::rename(label = "Description") %>%
  dplyr::rename_with(tolower)

ADSL %>% dplyr::select(STUDYID) %>%
  xportr_metadata(var_spec, "ADSL") %>%
  xportr_type(verbose = "warn") %>%
  xportr_length(verbose = "warn") %>%
  xportr_label(verbose = "warn") %>%
  xportr_order(verbose = "warn") %>%
  xportr_format() %>%
  xportr_df_label(dataset_spec, "ADSL") %>%
  xportr_write("adsl.xpt")
#> 
#> ── All variables in specification file are in dataset ──
#> 
#> ── All variables in dataset are ordered ──
#> 

Session Information

sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.3 (2023-03-15)
#>  os       Ubuntu 22.04.4 LTS
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       Etc/UTC
#>  date     2024-04-10
#>  pandoc   2.19.2 @ /usr/lib/rstudio-server/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date (UTC) lib source
#>  backports     1.4.1   2021-12-13 [1] RSPM (R 4.2.0)
#>  cellranger    1.1.0   2016-07-27 [1] RSPM (R 4.2.0)
#>  checkmate     2.1.0   2022-04-21 [1] RSPM
#>  cli           3.6.2   2023-12-11 [1] RSPM (R 4.2.0)
#>  digest        0.6.34  2024-01-11 [1] RSPM (R 4.2.0)
#>  dplyr       * 1.1.4   2023-11-17 [1] RSPM (R 4.2.0)
#>  evaluate      0.20    2023-01-17 [1] RSPM (R 4.2.0)
#>  fansi         1.0.4   2023-01-22 [1] RSPM
#>  fastmap       1.1.1   2023-02-24 [1] RSPM
#>  forcats       1.0.0   2023-01-29 [1] RSPM
#>  fs            1.6.3   2023-07-20 [1] RSPM (R 4.2.0)
#>  generics      0.1.3   2022-07-05 [1] RSPM
#>  glue          1.7.0   2024-01-09 [1] RSPM (R 4.2.0)
#>  haven         2.5.4   2023-11-30 [1] RSPM (R 4.2.0)
#>  hms           1.1.3   2023-03-21 [1] RSPM (R 4.2.0)
#>  htmltools     0.5.5   2023-03-23 [1] RSPM
#>  knitr         1.42    2023-01-25 [1] RSPM (R 4.2.0)
#>  lifecycle     1.0.4   2023-11-07 [1] RSPM (R 4.2.0)
#>  magrittr      2.0.3   2022-03-30 [1] RSPM (R 4.2.0)
#>  pillar        1.9.0   2023-03-22 [1] RSPM (R 4.2.0)
#>  pkgconfig     2.0.3   2019-09-22 [1] RSPM (R 4.2.0)
#>  purrr         1.0.2   2023-08-10 [1] RSPM (R 4.2.0)
#>  R.cache       0.16.0  2022-07-21 [1] RSPM
#>  R.methodsS3   1.8.2   2022-06-13 [1] RSPM
#>  R.oo          1.25.0  2022-06-12 [1] RSPM
#>  R.utils       2.12.2  2022-11-11 [1] RSPM
#>  R6            2.5.1   2021-08-19 [1] RSPM (R 4.2.0)
#>  readr         2.1.5   2024-01-10 [1] RSPM (R 4.2.0)
#>  readxl        1.4.3   2023-07-06 [1] RSPM (R 4.2.0)
#>  reprex        2.0.2   2022-08-17 [1] RSPM (R 4.2.0)
#>  rlang         1.1.3   2024-01-10 [1] RSPM (R 4.2.0)
#>  rmarkdown     2.21    2023-03-26 [1] RSPM (R 4.2.0)
#>  rstudioapi    0.14    2022-08-22 [1] RSPM (R 4.2.0)
#>  sessioninfo   1.2.2   2021-12-06 [1] RSPM (R 4.2.0)
#>  stringi       1.7.12  2023-01-11 [1] RSPM
#>  stringr       1.5.1   2023-11-14 [1] RSPM (R 4.2.0)
#>  styler        1.9.1   2023-03-04 [1] RSPM
#>  tibble        3.2.1   2023-03-20 [1] RSPM (R 4.2.0)
#>  tidyselect    1.2.0   2022-10-10 [1] RSPM (R 4.2.0)
#>  tzdb          0.3.0   2022-03-28 [1] RSPM (R 4.2.0)
#>  utf8          1.2.3   2023-01-31 [1] RSPM
#>  vctrs         0.6.5   2023-12-01 [1] RSPM (R 4.2.0)
#>  withr         3.0.0   2024-01-16 [1] RSPM (R 4.2.0)
#>  xfun          0.38    2023-03-24 [1] RSPM (R 4.2.0)
#>  xportr      * 0.4.0   2024-04-10 [1] Github (atorus-research/xportr@1a612ed)
#>  yaml          2.3.7   2023-01-23 [1] RSPM
#> 
#>  [1] /usr/local/lib/R/site-library
#>  [2] /usr/local/lib/R/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

ummm...that doesn't look right!! Thanks for flagging this @ynsec37!!

@atorus-research/xportr-development-team can anyone take a look at this please?

@bms63 I can take this up once I'm back from vacation

Thank you Eli!! I'm surprised we don't have a test for this.