├── docs
├── CNAME
├── logo.png
├── favicon.ico
├── favicon-16x16.png
├── favicon-32x32.png
├── apple-touch-icon.png
├── reference
│ ├── Rplot001.png
│ └── libr-package.html
├── man
│ └── images
│ │ ├── example1a.png
│ │ ├── example1b.png
│ │ ├── example1c.png
│ │ ├── example2.png
│ │ ├── lib_load.png
│ │ ├── libr_new.png
│ │ └── archive
│ │ └── books.svg
├── apple-touch-icon-60x60.png
├── apple-touch-icon-76x76.png
├── apple-touch-icon-120x120.png
├── apple-touch-icon-152x152.png
├── apple-touch-icon-180x180.png
├── extra.js
├── pkgdown.yml
├── articles
│ ├── libr_files
│ │ ├── header-attrs-2.11
│ │ │ └── header-attrs.js
│ │ ├── header-attrs-2.14
│ │ │ └── header-attrs.js
│ │ ├── header-attrs-2.6
│ │ │ └── header-attrs.js
│ │ ├── header-attrs-2.7
│ │ │ └── header-attrs.js
│ │ ├── header-attrs-2.8
│ │ │ └── header-attrs.js
│ │ ├── header-attrs-2.9
│ │ │ └── header-attrs.js
│ │ └── accessible-code-block-0.0.1
│ │ │ └── empty-anchor.js
│ ├── libr-basics_files
│ │ ├── header-attrs-2.11
│ │ │ └── header-attrs.js
│ │ ├── header-attrs-2.14
│ │ │ └── header-attrs.js
│ │ ├── header-attrs-2.6
│ │ │ └── header-attrs.js
│ │ ├── header-attrs-2.7
│ │ │ └── header-attrs.js
│ │ ├── header-attrs-2.8
│ │ │ └── header-attrs.js
│ │ ├── header-attrs-2.9
│ │ │ └── header-attrs.js
│ │ └── accessible-code-block-0.0.1
│ │ │ └── empty-anchor.js
│ ├── libr-faq_files
│ │ ├── header-attrs-2.11
│ │ │ └── header-attrs.js
│ │ └── header-attrs-2.14
│ │ │ └── header-attrs.js
│ ├── libr-datastep_files
│ │ ├── header-attrs-2.11
│ │ │ └── header-attrs.js
│ │ ├── header-attrs-2.14
│ │ │ └── header-attrs.js
│ │ ├── header-attrs-2.6
│ │ │ └── header-attrs.js
│ │ ├── header-attrs-2.7
│ │ │ └── header-attrs.js
│ │ ├── header-attrs-2.8
│ │ │ └── header-attrs.js
│ │ ├── header-attrs-2.9
│ │ │ └── header-attrs.js
│ │ └── accessible-code-block-0.0.1
│ │ │ └── empty-anchor.js
│ ├── libr-disclaimer_files
│ │ ├── header-attrs-2.11
│ │ │ └── header-attrs.js
│ │ ├── header-attrs-2.14
│ │ │ └── header-attrs.js
│ │ ├── header-attrs-2.6
│ │ │ └── header-attrs.js
│ │ ├── header-attrs-2.7
│ │ │ └── header-attrs.js
│ │ ├── header-attrs-2.8
│ │ │ └── header-attrs.js
│ │ ├── header-attrs-2.9
│ │ │ └── header-attrs.js
│ │ └── accessible-code-block-0.0.1
│ │ │ └── empty-anchor.js
│ ├── libr-example1_files
│ │ ├── header-attrs-2.11
│ │ │ └── header-attrs.js
│ │ └── header-attrs-2.14
│ │ │ └── header-attrs.js
│ ├── libr-example2_files
│ │ ├── header-attrs-2.11
│ │ │ └── header-attrs.js
│ │ └── header-attrs-2.14
│ │ │ └── header-attrs.js
│ └── libr-management_files
│ │ ├── header-attrs-2.11
│ │ └── header-attrs.js
│ │ ├── header-attrs-2.14
│ │ └── header-attrs.js
│ │ ├── header-attrs-2.6
│ │ └── header-attrs.js
│ │ ├── header-attrs-2.7
│ │ └── header-attrs.js
│ │ ├── header-attrs-2.8
│ │ └── header-attrs.js
│ │ ├── header-attrs-2.9
│ │ └── header-attrs.js
│ │ └── accessible-code-block-0.0.1
│ │ └── empty-anchor.js
├── link.svg
├── bootstrap-toc.css
├── docsearch.js
├── sitemap.xml
├── pkgdown.js
└── bootstrap-toc.js
├── .github
├── .gitignore
├── FUNDING.yml
└── workflows
│ └── R-CMD-check.yaml
├── tests
├── testthat
│ ├── data2
│ │ └── keep.txt
│ ├── data
│ │ ├── PE
│ │ │ ├── PE.xls
│ │ │ └── PE.xlsx
│ │ ├── adae.xpt
│ │ ├── adsl.xpt
│ │ ├── vect.rds
│ │ ├── SDTM
│ │ │ ├── DM.rds
│ │ │ ├── SV.rds
│ │ │ ├── SV2.rds
│ │ │ ├── VS.rds
│ │ │ ├── RANPOP.rds
│ │ │ ├── ae.sas7bdat
│ │ │ ├── da.sas7bdat
│ │ │ ├── dm.sas7bdat
│ │ │ ├── ds.sas7bdat
│ │ │ ├── ex.sas7bdat
│ │ │ ├── ie.sas7bdat
│ │ │ ├── lb.sas7bdat
│ │ │ ├── pe.sas7bdat
│ │ │ ├── sv.sas7bdat
│ │ │ ├── vs.sas7bdat
│ │ │ ├── suppex.sas7bdat
│ │ │ ├── IE.csv
│ │ │ └── EX.csv
│ │ ├── CRF
│ │ │ ├── dm.sas7bdat
│ │ │ └── pe.sas7bdat
│ │ ├── demo_studya.Rdata
│ │ ├── demo_studya.dbf
│ │ ├── demo_studya.rda
│ │ ├── demo_studya.rds
│ │ ├── demo_studya.xls
│ │ ├── demo_studya.xlsx
│ │ ├── demo_studya.xpt
│ │ ├── demo_studyb.Rdata
│ │ ├── demo_studyb.dbf
│ │ ├── demo_studyb.rda
│ │ ├── demo_studyb.rds
│ │ ├── demo_studyb.xls
│ │ ├── demo_studyb.xlsx
│ │ ├── demo_studyb.xpt
│ │ ├── demo_studya.parquet
│ │ ├── demo_studyb.parquet
│ │ ├── demo_studya.sas7bdat
│ │ ├── demo_studyb.sas7bdat
│ │ ├── empty
│ │ │ └── empty.sas7bdat
│ │ ├── demo_studyb.csv
│ │ └── demo_studya.csv
│ ├── programs
│ │ └── dstest.R
│ ├── test-utilities.R
│ ├── test-dsattr.R
│ └── test-dictionary.R
└── testthat.R
├── src
├── .gitignore
├── RcppExports.cpp
└── dshelpers.cpp
├── vignettes
├── .gitignore
├── libr-disclaimer.Rmd
├── libr-basics.Rmd
└── libr-management.Rmd
├── logo.png
├── .gitignore
├── man
├── images
│ ├── example1a.png
│ ├── example1b.png
│ ├── example1c.png
│ ├── example2.png
│ ├── lib_load.png
│ ├── libr_new.png
│ ├── logr_new.png
│ └── archive
│ │ ├── libr1.png
│ │ ├── libr_blue.png
│ │ └── books.svg
├── print.specs.Rd
├── length.dsarray.Rd
├── is.lib.Rd
├── lib_path.Rd
├── write.specs.Rd
├── lib_size.Rd
├── read.specs.Rd
├── delete.Rd
├── lib_info.Rd
├── print.lib.Rd
├── lib_delete.Rd
├── lib_remove.Rd
├── lib_unload.Rd
├── lib_add.Rd
├── lib_replace.Rd
├── import_spec.Rd
├── lib_copy.Rd
├── lib_load.Rd
├── lib_sync.Rd
├── libr.Rd
├── dictionary.Rd
├── output.Rd
├── lib_export.Rd
├── sub-.dsarray.Rd
├── lib_write.Rd
├── dsarray.Rd
├── dsattr.Rd
└── specs.Rd
├── inst
└── extdata
│ ├── libr_data.zip
│ ├── IE.csv
│ └── EX.csv
├── pkgdown
├── favicon
│ ├── favicon.ico
│ ├── favicon-16x16.png
│ ├── favicon-32x32.png
│ ├── apple-touch-icon.png
│ ├── apple-touch-icon-60x60.png
│ ├── apple-touch-icon-76x76.png
│ ├── apple-touch-icon-120x120.png
│ ├── apple-touch-icon-152x152.png
│ └── apple-touch-icon-180x180.png
└── extra.js
├── R
├── libr-package.R
├── RcppExports.R
├── experiments.R
├── libr.R
├── dshelpers.R
├── dsattr.R
└── dictionary.R
├── .Rbuildignore
├── .travis.yml
├── codecov.yml
├── libr.Rproj
├── NAMESPACE
├── _pkgdown.yml
├── DESCRIPTION
└── README.md
/docs/CNAME:
--------------------------------------------------------------------------------
1 | libr.r-sassy.org
--------------------------------------------------------------------------------
/.github/.gitignore:
--------------------------------------------------------------------------------
1 | *.html
2 |
--------------------------------------------------------------------------------
/tests/testthat/data2/keep.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: [dbosak01]
2 |
--------------------------------------------------------------------------------
/src/.gitignore:
--------------------------------------------------------------------------------
1 | *.o
2 | *.so
3 | *.dll
4 |
--------------------------------------------------------------------------------
/vignettes/.gitignore:
--------------------------------------------------------------------------------
1 | *.html
2 | *.R
3 |
--------------------------------------------------------------------------------
/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/logo.png
--------------------------------------------------------------------------------
/docs/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/docs/logo.png
--------------------------------------------------------------------------------
/docs/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/docs/favicon.ico
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .Rproj.user
2 | .Rhistory
3 | .RData
4 | .Ruserdata
5 | inst/doc
6 |
7 |
--------------------------------------------------------------------------------
/tests/testthat.R:
--------------------------------------------------------------------------------
1 | library(testthat)
2 | library(libr)
3 |
4 | test_check("libr")
5 |
--------------------------------------------------------------------------------
/docs/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/docs/favicon-16x16.png
--------------------------------------------------------------------------------
/docs/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/docs/favicon-32x32.png
--------------------------------------------------------------------------------
/man/images/example1a.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/man/images/example1a.png
--------------------------------------------------------------------------------
/man/images/example1b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/man/images/example1b.png
--------------------------------------------------------------------------------
/man/images/example1c.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/man/images/example1c.png
--------------------------------------------------------------------------------
/man/images/example2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/man/images/example2.png
--------------------------------------------------------------------------------
/man/images/lib_load.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/man/images/lib_load.png
--------------------------------------------------------------------------------
/man/images/libr_new.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/man/images/libr_new.png
--------------------------------------------------------------------------------
/man/images/logr_new.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/man/images/logr_new.png
--------------------------------------------------------------------------------
/docs/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/docs/apple-touch-icon.png
--------------------------------------------------------------------------------
/docs/reference/Rplot001.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/docs/reference/Rplot001.png
--------------------------------------------------------------------------------
/inst/extdata/libr_data.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/inst/extdata/libr_data.zip
--------------------------------------------------------------------------------
/pkgdown/favicon/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/pkgdown/favicon/favicon.ico
--------------------------------------------------------------------------------
/docs/man/images/example1a.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/docs/man/images/example1a.png
--------------------------------------------------------------------------------
/docs/man/images/example1b.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/docs/man/images/example1b.png
--------------------------------------------------------------------------------
/docs/man/images/example1c.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/docs/man/images/example1c.png
--------------------------------------------------------------------------------
/docs/man/images/example2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/docs/man/images/example2.png
--------------------------------------------------------------------------------
/docs/man/images/lib_load.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/docs/man/images/lib_load.png
--------------------------------------------------------------------------------
/docs/man/images/libr_new.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/docs/man/images/libr_new.png
--------------------------------------------------------------------------------
/man/images/archive/libr1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/man/images/archive/libr1.png
--------------------------------------------------------------------------------
/tests/testthat/data/PE/PE.xls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/PE/PE.xls
--------------------------------------------------------------------------------
/tests/testthat/data/adae.xpt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/adae.xpt
--------------------------------------------------------------------------------
/tests/testthat/data/adsl.xpt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/adsl.xpt
--------------------------------------------------------------------------------
/tests/testthat/data/vect.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/vect.rds
--------------------------------------------------------------------------------
/docs/apple-touch-icon-60x60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/docs/apple-touch-icon-60x60.png
--------------------------------------------------------------------------------
/docs/apple-touch-icon-76x76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/docs/apple-touch-icon-76x76.png
--------------------------------------------------------------------------------
/man/images/archive/libr_blue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/man/images/archive/libr_blue.png
--------------------------------------------------------------------------------
/tests/testthat/data/PE/PE.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/PE/PE.xlsx
--------------------------------------------------------------------------------
/tests/testthat/data/SDTM/DM.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/SDTM/DM.rds
--------------------------------------------------------------------------------
/tests/testthat/data/SDTM/SV.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/SDTM/SV.rds
--------------------------------------------------------------------------------
/tests/testthat/data/SDTM/SV2.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/SDTM/SV2.rds
--------------------------------------------------------------------------------
/tests/testthat/data/SDTM/VS.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/SDTM/VS.rds
--------------------------------------------------------------------------------
/docs/apple-touch-icon-120x120.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/docs/apple-touch-icon-120x120.png
--------------------------------------------------------------------------------
/docs/apple-touch-icon-152x152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/docs/apple-touch-icon-152x152.png
--------------------------------------------------------------------------------
/docs/apple-touch-icon-180x180.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/docs/apple-touch-icon-180x180.png
--------------------------------------------------------------------------------
/pkgdown/favicon/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/pkgdown/favicon/favicon-16x16.png
--------------------------------------------------------------------------------
/pkgdown/favicon/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/pkgdown/favicon/favicon-32x32.png
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/pkgdown/favicon/apple-touch-icon.png
--------------------------------------------------------------------------------
/tests/testthat/data/CRF/dm.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/CRF/dm.sas7bdat
--------------------------------------------------------------------------------
/tests/testthat/data/CRF/pe.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/CRF/pe.sas7bdat
--------------------------------------------------------------------------------
/tests/testthat/data/SDTM/RANPOP.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/SDTM/RANPOP.rds
--------------------------------------------------------------------------------
/tests/testthat/data/SDTM/ae.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/SDTM/ae.sas7bdat
--------------------------------------------------------------------------------
/tests/testthat/data/SDTM/da.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/SDTM/da.sas7bdat
--------------------------------------------------------------------------------
/tests/testthat/data/SDTM/dm.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/SDTM/dm.sas7bdat
--------------------------------------------------------------------------------
/tests/testthat/data/SDTM/ds.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/SDTM/ds.sas7bdat
--------------------------------------------------------------------------------
/tests/testthat/data/SDTM/ex.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/SDTM/ex.sas7bdat
--------------------------------------------------------------------------------
/tests/testthat/data/SDTM/ie.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/SDTM/ie.sas7bdat
--------------------------------------------------------------------------------
/tests/testthat/data/SDTM/lb.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/SDTM/lb.sas7bdat
--------------------------------------------------------------------------------
/tests/testthat/data/SDTM/pe.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/SDTM/pe.sas7bdat
--------------------------------------------------------------------------------
/tests/testthat/data/SDTM/sv.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/SDTM/sv.sas7bdat
--------------------------------------------------------------------------------
/tests/testthat/data/SDTM/vs.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/SDTM/vs.sas7bdat
--------------------------------------------------------------------------------
/tests/testthat/data/demo_studya.Rdata:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/demo_studya.Rdata
--------------------------------------------------------------------------------
/tests/testthat/data/demo_studya.dbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/demo_studya.dbf
--------------------------------------------------------------------------------
/tests/testthat/data/demo_studya.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/demo_studya.rda
--------------------------------------------------------------------------------
/tests/testthat/data/demo_studya.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/demo_studya.rds
--------------------------------------------------------------------------------
/tests/testthat/data/demo_studya.xls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/demo_studya.xls
--------------------------------------------------------------------------------
/tests/testthat/data/demo_studya.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/demo_studya.xlsx
--------------------------------------------------------------------------------
/tests/testthat/data/demo_studya.xpt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/demo_studya.xpt
--------------------------------------------------------------------------------
/tests/testthat/data/demo_studyb.Rdata:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/demo_studyb.Rdata
--------------------------------------------------------------------------------
/tests/testthat/data/demo_studyb.dbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/demo_studyb.dbf
--------------------------------------------------------------------------------
/tests/testthat/data/demo_studyb.rda:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/demo_studyb.rda
--------------------------------------------------------------------------------
/tests/testthat/data/demo_studyb.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/demo_studyb.rds
--------------------------------------------------------------------------------
/tests/testthat/data/demo_studyb.xls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/demo_studyb.xls
--------------------------------------------------------------------------------
/tests/testthat/data/demo_studyb.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/demo_studyb.xlsx
--------------------------------------------------------------------------------
/tests/testthat/data/demo_studyb.xpt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/demo_studyb.xpt
--------------------------------------------------------------------------------
/tests/testthat/data/demo_studya.parquet:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/demo_studya.parquet
--------------------------------------------------------------------------------
/tests/testthat/data/demo_studyb.parquet:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/demo_studyb.parquet
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon-60x60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/pkgdown/favicon/apple-touch-icon-60x60.png
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon-76x76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/pkgdown/favicon/apple-touch-icon-76x76.png
--------------------------------------------------------------------------------
/tests/testthat/data/SDTM/suppex.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/SDTM/suppex.sas7bdat
--------------------------------------------------------------------------------
/tests/testthat/data/demo_studya.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/demo_studya.sas7bdat
--------------------------------------------------------------------------------
/tests/testthat/data/demo_studyb.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/demo_studyb.sas7bdat
--------------------------------------------------------------------------------
/tests/testthat/data/empty/empty.sas7bdat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/tests/testthat/data/empty/empty.sas7bdat
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon-120x120.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/pkgdown/favicon/apple-touch-icon-120x120.png
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon-152x152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/pkgdown/favicon/apple-touch-icon-152x152.png
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon-180x180.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dbosak01/libr/HEAD/pkgdown/favicon/apple-touch-icon-180x180.png
--------------------------------------------------------------------------------
/R/libr-package.R:
--------------------------------------------------------------------------------
1 | ## usethis namespace: start
2 | #' @importFrom Rcpp sourceCpp
3 | #' @useDynLib libr
4 | ## usethis namespace: end
5 | NULL
6 |
--------------------------------------------------------------------------------
/.Rbuildignore:
--------------------------------------------------------------------------------
1 | ^.*\.Rproj$
2 | ^\.Rproj\.user$
3 | ^\.travis\.yml$
4 | ^_pkgdown\.yml$
5 | ^docs$
6 | ^pkgdown$
7 | ^logo\.png$
8 | ^\.github$
9 | ^codecov\.yml$
10 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | # R for travis: see documentation at https://docs.travis-ci.com/user/languages/r
2 |
3 | language: R
4 | cache: packages
5 | after_success:
6 | - Rscript -e 'covr::codecov()'
7 |
--------------------------------------------------------------------------------
/tests/testthat/data/demo_studyb.csv:
--------------------------------------------------------------------------------
1 | study,inv,patient,visit,screendate,sex,race,dob,treatment
2 | StudyB,2000,1,0,2020-02-19,M,White,1986-01-11,Active
3 | StudyB,2000,2,0,2020-02-19,F,African American,1987-07-01,Placebo
4 |
--------------------------------------------------------------------------------
/codecov.yml:
--------------------------------------------------------------------------------
1 | comment: false
2 |
3 | coverage:
4 | status:
5 | project:
6 | default:
7 | target: auto
8 | threshold: 1%
9 | informational: true
10 | patch:
11 | default:
12 | target: auto
13 | threshold: 1%
14 | informational: true
15 |
--------------------------------------------------------------------------------
/docs/reference/libr-package.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/docs/extra.js:
--------------------------------------------------------------------------------
1 |
2 |
3 | window.addEventListener('load', (event) => {
4 |
5 | var br = document.getElementsByClassName("navbar-brand")[0]
6 |
7 | tg = 'part of the sassy system'
8 |
9 | br.innerHTML = br.innerHTML + tg
10 | });
11 |
12 |
--------------------------------------------------------------------------------
/pkgdown/extra.js:
--------------------------------------------------------------------------------
1 |
2 |
3 | window.addEventListener('load', (event) => {
4 |
5 | var br = document.getElementsByClassName("navbar-brand")[0]
6 |
7 | tg = 'part of the sassy system'
8 |
9 | br.innerHTML = br.innerHTML + tg
10 | });
11 |
12 |
--------------------------------------------------------------------------------
/inst/extdata/IE.csv:
--------------------------------------------------------------------------------
1 | STUDYID,DOMAIN,USUBJID,IESEQ,IETESTCD,IETEST,IECAT,IEORRES,IESTRESC,VISITNUM,VISIT,VISITDY,IEDTC,IEDY
2 | ABC,IE,ABC-03-090,1,IN01,Subject must be between the ages of 18 and 75 years old inclusive.,INCLUSION,N,N,1,DAY 1,1,2006-12-06,1
3 | ABC,IE,ABC-06-162,1,EX11,Subject cannot have a history of hypercalcemia or kidney stones.,EXCLUSION,Y,Y,1,DAY 1,1,2006-12-28,1
4 |
--------------------------------------------------------------------------------
/tests/testthat/data/SDTM/IE.csv:
--------------------------------------------------------------------------------
1 | STUDYID,DOMAIN,USUBJID,IESEQ,IETESTCD,IETEST,IECAT,IEORRES,IESTRESC,VISITNUM,VISIT,VISITDY,IEDTC,IEDY
2 | ABC,IE,ABC-03-090,1,IN01,Subject must be between the ages of 18 and 75 years old inclusive.,INCLUSION,N,N,1,DAY 1,1,2006-12-06,1
3 | ABC,IE,ABC-06-162,1,EX11,Subject cannot have a history of hypercalcemia or kidney stones.,EXCLUSION,Y,Y,1,DAY 1,1,2006-12-28,1
4 |
--------------------------------------------------------------------------------
/tests/testthat/programs/dstest.R:
--------------------------------------------------------------------------------
1 | library(fmtr)
2 |
3 | myfmt <- value(condition(x >= 20, "High"),
4 | condition(x < 20, "Low"))
5 |
6 |
7 | d1 <- datastep(mtcars, {
8 |
9 | mpgcat <- fapply(mpg, myfmt)
10 |
11 | })
12 |
13 |
14 | d1
15 |
16 |
17 | if (!"mpgcat" %in% names(d1))
18 | stop("Mpgcat missing")
19 |
20 |
21 | if (d1$mpgcat[1] != "High")
22 | stop("Mpgcat value not High")
23 |
--------------------------------------------------------------------------------
/docs/pkgdown.yml:
--------------------------------------------------------------------------------
1 | pandoc: 3.6.3
2 | pkgdown: 2.1.0
3 | pkgdown_sha: ~
4 | articles:
5 | libr-basics: libr-basics.html
6 | libr-datastep: libr-datastep.html
7 | libr-disclaimer: libr-disclaimer.html
8 | libr-example1: libr-example1.html
9 | libr-example2: libr-example2.html
10 | libr-faq: libr-faq.html
11 | libr-management: libr-management.html
12 | libr: libr.html
13 | last_built: 2025-12-13T03:38Z
14 | urls:
15 | reference: https://libr.r-sassy.org/reference
16 | article: https://libr.r-sassy.org/articles
17 |
--------------------------------------------------------------------------------
/R/RcppExports.R:
--------------------------------------------------------------------------------
1 | # Generated by using Rcpp::compileAttributes() -> do not edit by hand
2 | # Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
3 |
4 | bychanges <- function(dat) {
5 | .Call('_libr_bychanges', PACKAGE = 'libr', dat)
6 | }
7 |
8 | byfirst <- function(dat) {
9 | .Call('_libr_byfirst', PACKAGE = 'libr', dat)
10 | }
11 |
12 | bylast <- function(dat) {
13 | .Call('_libr_bylast', PACKAGE = 'libr', dat)
14 | }
15 |
16 | getsigs <- function(dat) {
17 | .Call('_libr_getsigs', PACKAGE = 'libr', dat)
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/libr.Rproj:
--------------------------------------------------------------------------------
1 | Version: 1.0
2 | ProjectId: 8588c82f-92c0-4d1c-8d6d-c2e18cf15707
3 |
4 | RestoreWorkspace: Default
5 | SaveWorkspace: Default
6 | AlwaysSaveHistory: Default
7 |
8 | EnableCodeIndexing: Yes
9 | UseSpacesForTab: Yes
10 | NumSpacesForTab: 2
11 | Encoding: UTF-8
12 |
13 | RnwWeave: Sweave
14 | LaTeX: pdfLaTeX
15 |
16 | AutoAppendNewline: Yes
17 |
18 | BuildType: Package
19 | PackageUseDevtools: Yes
20 | PackageInstallArgs: --no-multiarch --with-keep.source
21 | PackageCheckArgs: --as-cran
22 | PackageRoxygenize: rd,collate,namespace,vignette
23 |
--------------------------------------------------------------------------------
/docs/articles/libr_files/header-attrs-2.11/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr_files/header-attrs-2.14/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr_files/header-attrs-2.6/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr_files/header-attrs-2.7/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr_files/header-attrs-2.8/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr_files/header-attrs-2.9/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-basics_files/header-attrs-2.11/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-basics_files/header-attrs-2.14/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-basics_files/header-attrs-2.6/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-basics_files/header-attrs-2.7/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-basics_files/header-attrs-2.8/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-basics_files/header-attrs-2.9/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-faq_files/header-attrs-2.11/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-faq_files/header-attrs-2.14/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-datastep_files/header-attrs-2.11/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-datastep_files/header-attrs-2.14/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-datastep_files/header-attrs-2.6/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-datastep_files/header-attrs-2.7/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-datastep_files/header-attrs-2.8/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-datastep_files/header-attrs-2.9/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-disclaimer_files/header-attrs-2.11/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-disclaimer_files/header-attrs-2.14/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-disclaimer_files/header-attrs-2.6/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-disclaimer_files/header-attrs-2.7/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-disclaimer_files/header-attrs-2.8/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-disclaimer_files/header-attrs-2.9/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-example1_files/header-attrs-2.11/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-example1_files/header-attrs-2.14/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-example2_files/header-attrs-2.11/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-example2_files/header-attrs-2.14/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-management_files/header-attrs-2.11/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-management_files/header-attrs-2.14/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-management_files/header-attrs-2.6/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-management_files/header-attrs-2.7/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-management_files/header-attrs-2.8/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/docs/articles/libr-management_files/header-attrs-2.9/header-attrs.js:
--------------------------------------------------------------------------------
1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to
2 | // be compatible with the behavior of Pandoc < 2.8).
3 | document.addEventListener('DOMContentLoaded', function(e) {
4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
5 | var i, h, a;
6 | for (i = 0; i < hs.length; i++) {
7 | h = hs[i];
8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
9 | a = h.attributes;
10 | while (a.length > 0) h.removeAttribute(a[0].name);
11 | }
12 | });
13 |
--------------------------------------------------------------------------------
/tests/testthat/data/demo_studya.csv:
--------------------------------------------------------------------------------
1 | study,inv,patient,visit,screendate,sex,race,dob,treatment
2 | StudyA,1000,1,0,2020-01-03,M,White,1990-01-31,Placebo
3 | StudyA,1000,2,0,2020-01-02,F,African American,1989-12-09,Placebo
4 | StudyA,1010,3,0,2020-01-03,M,Asian,1992-02-26,Placebo
5 | StudyA,1010,4,0,2020-01-03,M,White,1991-07-04,Placebo
6 | StudyA,1010,5,0,2020-01-02,F,African American,1990-06-30,Active
7 | StudyA,1000,7,0,2020-01-03,M,White,1990-10-31,Active
8 | StudyA,1000,7,0,2020-01-03,M,White,1990-10-31,Active
9 | StudyA,1000,8,0,2020-01-02,F,African American,1988-09-12,Active
10 | StudyA,1010,9,0,2020-01-03,M,Asian,1993-04-22,Active
11 | StudyA,1010,10,0,2020-01-03,M,White,1994-09-05,Active
12 |
--------------------------------------------------------------------------------
/vignettes/libr-disclaimer.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Disclaimer"
3 | output: rmarkdown::html_vignette
4 | vignette: >
5 | %\VignetteIndexEntry{Disclaimer}
6 | %\VignetteEngine{knitr::rmarkdown}
7 | %\VignetteEncoding{UTF-8}
8 | ---
9 |
10 | ```{r setup, include = FALSE}
11 | knitr::opts_chunk$set(
12 | collapse = TRUE,
13 | comment = "#>"
14 | )
15 | ```
16 |
17 | Note that the **libr** package is intended to be used with small and
18 | medium-sized data sets. It is not recommended for big data, as big data
19 | requires very careful control over which data is or is not loaded into memory.
20 | The **libr** package, on the other hand, tends to load all data into memory
21 | indiscriminately.
22 |
23 | Next: [Complete Example 1](libr-example1.html)
24 |
--------------------------------------------------------------------------------
/docs/articles/libr_files/accessible-code-block-0.0.1/empty-anchor.js:
--------------------------------------------------------------------------------
1 | // Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) -->
2 | // v0.0.1
3 | // Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020.
4 |
5 | document.addEventListener('DOMContentLoaded', function() {
6 | const codeList = document.getElementsByClassName("sourceCode");
7 | for (var i = 0; i < codeList.length; i++) {
8 | var linkList = codeList[i].getElementsByTagName('a');
9 | for (var j = 0; j < linkList.length; j++) {
10 | if (linkList[j].innerHTML === "") {
11 | linkList[j].setAttribute('aria-hidden', 'true');
12 | }
13 | }
14 | }
15 | });
16 |
--------------------------------------------------------------------------------
/docs/articles/libr-basics_files/accessible-code-block-0.0.1/empty-anchor.js:
--------------------------------------------------------------------------------
1 | // Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) -->
2 | // v0.0.1
3 | // Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020.
4 |
5 | document.addEventListener('DOMContentLoaded', function() {
6 | const codeList = document.getElementsByClassName("sourceCode");
7 | for (var i = 0; i < codeList.length; i++) {
8 | var linkList = codeList[i].getElementsByTagName('a');
9 | for (var j = 0; j < linkList.length; j++) {
10 | if (linkList[j].innerHTML === "") {
11 | linkList[j].setAttribute('aria-hidden', 'true');
12 | }
13 | }
14 | }
15 | });
16 |
--------------------------------------------------------------------------------
/docs/articles/libr-datastep_files/accessible-code-block-0.0.1/empty-anchor.js:
--------------------------------------------------------------------------------
1 | // Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) -->
2 | // v0.0.1
3 | // Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020.
4 |
5 | document.addEventListener('DOMContentLoaded', function() {
6 | const codeList = document.getElementsByClassName("sourceCode");
7 | for (var i = 0; i < codeList.length; i++) {
8 | var linkList = codeList[i].getElementsByTagName('a');
9 | for (var j = 0; j < linkList.length; j++) {
10 | if (linkList[j].innerHTML === "") {
11 | linkList[j].setAttribute('aria-hidden', 'true');
12 | }
13 | }
14 | }
15 | });
16 |
--------------------------------------------------------------------------------
/docs/articles/libr-disclaimer_files/accessible-code-block-0.0.1/empty-anchor.js:
--------------------------------------------------------------------------------
1 | // Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) -->
2 | // v0.0.1
3 | // Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020.
4 |
5 | document.addEventListener('DOMContentLoaded', function() {
6 | const codeList = document.getElementsByClassName("sourceCode");
7 | for (var i = 0; i < codeList.length; i++) {
8 | var linkList = codeList[i].getElementsByTagName('a');
9 | for (var j = 0; j < linkList.length; j++) {
10 | if (linkList[j].innerHTML === "") {
11 | linkList[j].setAttribute('aria-hidden', 'true');
12 | }
13 | }
14 | }
15 | });
16 |
--------------------------------------------------------------------------------
/docs/articles/libr-management_files/accessible-code-block-0.0.1/empty-anchor.js:
--------------------------------------------------------------------------------
1 | // Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) -->
2 | // v0.0.1
3 | // Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020.
4 |
5 | document.addEventListener('DOMContentLoaded', function() {
6 | const codeList = document.getElementsByClassName("sourceCode");
7 | for (var i = 0; i < codeList.length; i++) {
8 | var linkList = codeList[i].getElementsByTagName('a');
9 | for (var j = 0; j < linkList.length; j++) {
10 | if (linkList[j].innerHTML === "") {
11 | linkList[j].setAttribute('aria-hidden', 'true');
12 | }
13 | }
14 | }
15 | });
16 |
--------------------------------------------------------------------------------
/docs/link.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
13 |
--------------------------------------------------------------------------------
/man/print.specs.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/specs.R
3 | \name{print.specs}
4 | \alias{print.specs}
5 | \title{Print import specifications}
6 | \usage{
7 | \method{print}{specs}(x, ..., verbose = FALSE)
8 | }
9 | \arguments{
10 | \item{x}{The specifications to print.}
11 |
12 | \item{...}{Any follow-on parameters to the print function.}
13 |
14 | \item{verbose}{Whether or not to print the specifications in verbose style.
15 | By default, the parameter is FALSE, meaning to print in summary style.}
16 | }
17 | \value{
18 | The specification object, invisibly.
19 | }
20 | \description{
21 | A function to print the import specification collection.
22 | }
23 | \seealso{
24 | Other specs:
25 | \code{\link{import_spec}()},
26 | \code{\link{read.specs}()},
27 | \code{\link{specs}()},
28 | \code{\link{write.specs}()}
29 | }
30 | \concept{specs}
31 |
--------------------------------------------------------------------------------
/NAMESPACE:
--------------------------------------------------------------------------------
1 | # Generated by roxygen2: do not edit by hand
2 |
3 | S3method("[",dsarray)
4 | S3method(length,dsarray)
5 | S3method(print,lib)
6 | S3method(print,specs)
7 | export(datastep)
8 | export(delete)
9 | export(dictionary)
10 | export(dsarray)
11 | export(dsattr)
12 | export(import_spec)
13 | export(is.lib)
14 | export(lib_add)
15 | export(lib_copy)
16 | export(lib_delete)
17 | export(lib_export)
18 | export(lib_info)
19 | export(lib_load)
20 | export(lib_path)
21 | export(lib_remove)
22 | export(lib_replace)
23 | export(lib_size)
24 | export(lib_sync)
25 | export(lib_unload)
26 | export(lib_write)
27 | export(libname)
28 | export(output)
29 | export(read.specs)
30 | export(specs)
31 | export(write.specs)
32 | import(common)
33 | import(crayon)
34 | import(dplyr)
35 | import(haven)
36 | import(openxlsx)
37 | import(readr)
38 | import(readxl)
39 | import(tibble)
40 | import(tools)
41 | importFrom(Rcpp,sourceCpp)
42 | useDynLib(libr)
43 |
--------------------------------------------------------------------------------
/man/length.dsarray.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/dsarray.R
3 | \encoding{UTF-8}
4 | \name{length.dsarray}
5 | \alias{length.dsarray}
6 | \title{Length function for dsarray class}
7 | \usage{
8 | \method{length}{dsarray}(x)
9 | }
10 | \arguments{
11 | \item{x}{The \code{\link{dsarray}} object.}
12 | }
13 | \value{
14 | The number of items in the specified \code{\link{dsarray}}.
15 | }
16 | \description{
17 | A length function for the data step array \code{\link{dsarray}}.
18 | The length function can by used either inside or outside the data step.
19 | }
20 | \examples{
21 | # Define datastep array
22 | carr <- dsarray(names(mtcars))
23 |
24 | length(carr)
25 | # 11
26 | }
27 | \seealso{
28 | Other datastep:
29 | \code{\link{[.dsarray}()},
30 | \code{\link{datastep}()},
31 | \code{\link{delete}()},
32 | \code{\link{dsarray}()},
33 | \code{\link{dsattr}()},
34 | \code{\link{output}()}
35 | }
36 | \concept{datastep}
37 |
--------------------------------------------------------------------------------
/man/is.lib.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utilities.R
3 | \name{is.lib}
4 | \alias{is.lib}
5 | \title{Class test for a data library}
6 | \usage{
7 | is.lib(x)
8 | }
9 | \arguments{
10 | \item{x}{The object to test.}
11 | }
12 | \value{
13 | TRUE or FALSE, depending on whether or not the object is a
14 | data library.
15 | }
16 | \description{
17 | This function tests whether an object is a data library. The
18 | data library has a class of "lib".
19 | }
20 | \examples{
21 | # Create format catalog
22 | libname(dat, tempdir())
23 |
24 | # Test for "lib" class
25 | is.lib(dat)
26 | # [1] TRUE
27 |
28 | is.lib(list())
29 | # [1] FALSE
30 |
31 | # Clean up
32 | lib_delete(dat)
33 | }
34 | \seealso{
35 | Other lib:
36 | \code{\link{lib_add}()},
37 | \code{\link{lib_copy}()},
38 | \code{\link{lib_delete}()},
39 | \code{\link{lib_export}()},
40 | \code{\link{lib_info}()},
41 | \code{\link{lib_load}()},
42 | \code{\link{lib_path}()},
43 | \code{\link{lib_remove}()},
44 | \code{\link{lib_replace}()},
45 | \code{\link{lib_size}()},
46 | \code{\link{lib_sync}()},
47 | \code{\link{lib_unload}()},
48 | \code{\link{lib_write}()},
49 | \code{\link{libname}()},
50 | \code{\link{print.lib}()}
51 | }
52 | \concept{lib}
53 |
--------------------------------------------------------------------------------
/man/lib_path.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/libname.R
3 | \name{lib_path}
4 | \alias{lib_path}
5 | \title{Get the Path for a Data Library}
6 | \usage{
7 | lib_path(x)
8 | }
9 | \arguments{
10 | \item{x}{The data library.}
11 | }
12 | \value{
13 | The path of the data library as a single string.
14 | }
15 | \description{
16 | The \code{lib_path} function returns the current path of the
17 | the library as a string.
18 | }
19 | \examples{
20 | # Create temp directory
21 | tmp <- tempdir()
22 |
23 | # Create library
24 | libname(dat, tmp)
25 |
26 | # Examine library path
27 | lib_path(dat)
28 | # [1] "C:\\Users\\User\\AppData\\Local\\Temp\\RtmpCSJ6Gc"
29 |
30 | # Clean up
31 | lib_delete(dat)
32 | }
33 | \seealso{
34 | Other lib:
35 | \code{\link{is.lib}()},
36 | \code{\link{lib_add}()},
37 | \code{\link{lib_copy}()},
38 | \code{\link{lib_delete}()},
39 | \code{\link{lib_export}()},
40 | \code{\link{lib_info}()},
41 | \code{\link{lib_load}()},
42 | \code{\link{lib_remove}()},
43 | \code{\link{lib_replace}()},
44 | \code{\link{lib_size}()},
45 | \code{\link{lib_sync}()},
46 | \code{\link{lib_unload}()},
47 | \code{\link{lib_write}()},
48 | \code{\link{libname}()},
49 | \code{\link{print.lib}()}
50 | }
51 | \concept{lib}
52 |
--------------------------------------------------------------------------------
/man/write.specs.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/specs.R
3 | \name{write.specs}
4 | \alias{write.specs}
5 | \title{Write import specs to the file system}
6 | \usage{
7 | write.specs(x, dir_path = getwd(), file_name = NULL)
8 | }
9 | \arguments{
10 | \item{x}{A specifications object of class 'specs'.}
11 |
12 | \item{dir_path}{A full or relative path to save the specs. Default is the
13 | current working directory.}
14 |
15 | \item{file_name}{The file name to save to specs, without a file extension.
16 | The file extension will be added automatically. If no file name is
17 | supplied, the function will use the variable name as the file name.}
18 | }
19 | \value{
20 | The full file path.
21 | }
22 | \description{
23 | A function to write import specifications to the file system.
24 | The function accepts a specifications object and a full or relative
25 | path. The function returns the full file path. This function is
26 | useful so that you can define import specifications once, and reuse them
27 | in multiple programs or across multiple teams.
28 | }
29 | \seealso{
30 | Other specs:
31 | \code{\link{import_spec}()},
32 | \code{\link{print.specs}()},
33 | \code{\link{read.specs}()},
34 | \code{\link{specs}()}
35 | }
36 | \concept{specs}
37 |
--------------------------------------------------------------------------------
/man/lib_size.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/libname.R
3 | \name{lib_size}
4 | \alias{lib_size}
5 | \title{Get the Size of a Data Library}
6 | \usage{
7 | lib_size(x)
8 | }
9 | \arguments{
10 | \item{x}{The data library.}
11 | }
12 | \value{
13 | The size of the data library in bytes as stored on the file system.
14 | }
15 | \description{
16 | The \code{lib_size} function returns the number of bytes used
17 | by the data library, as stored on disk.
18 | }
19 | \examples{
20 | # Create temp directory
21 | tmp <- tempdir()
22 |
23 | # Create library
24 | libname(dat, tmp)
25 |
26 | # Add some data to library
27 | lib_add(dat, mtcars)
28 | lib_add(dat, iris)
29 |
30 | # Check size of library
31 | lib_size(dat)
32 | # [1] 9757
33 |
34 | # Clean up
35 | lib_delete(dat)
36 | }
37 | \seealso{
38 | Other lib:
39 | \code{\link{is.lib}()},
40 | \code{\link{lib_add}()},
41 | \code{\link{lib_copy}()},
42 | \code{\link{lib_delete}()},
43 | \code{\link{lib_export}()},
44 | \code{\link{lib_info}()},
45 | \code{\link{lib_load}()},
46 | \code{\link{lib_path}()},
47 | \code{\link{lib_remove}()},
48 | \code{\link{lib_replace}()},
49 | \code{\link{lib_sync}()},
50 | \code{\link{lib_unload}()},
51 | \code{\link{lib_write}()},
52 | \code{\link{libname}()},
53 | \code{\link{print.lib}()}
54 | }
55 | \concept{lib}
56 |
--------------------------------------------------------------------------------
/man/read.specs.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/specs.R
3 | \name{read.specs}
4 | \alias{read.specs}
5 | \title{Read import specs from the file system}
6 | \usage{
7 | read.specs(file_path = getwd())
8 | }
9 | \arguments{
10 | \item{file_path}{The full or relative path to the file system. Default is
11 | the current working directory. If the \code{file_path} is a file name that
12 | does not contain the '.specs' file extension, the function will add the
13 | extension. If the \code{file_path} contains a directory name,
14 | the function will search the directory for a file with an extension
15 | of '.specs'. If more than one file with an extension of '.specs' is founds,
16 | the function will generate an error.}
17 | }
18 | \value{
19 | The specifications object.
20 | }
21 | \description{
22 | A function to read import specifications from the file system.
23 | The function accepts a full or relative path to the spec file, and returns
24 | the specs as an object. If the \code{file_path} parameter is passed
25 | as a directory name, the function will search for a file with a '.specs'
26 | extension and read it.
27 | }
28 | \seealso{
29 | Other specs:
30 | \code{\link{import_spec}()},
31 | \code{\link{print.specs}()},
32 | \code{\link{specs}()},
33 | \code{\link{write.specs}()}
34 | }
35 | \concept{specs}
36 |
--------------------------------------------------------------------------------
/man/delete.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/datastep.R
3 | \name{delete}
4 | \alias{delete}
5 | \title{Removes an observation from a datastep}
6 | \usage{
7 | delete()
8 | }
9 | \value{
10 | Observation is marked with a delete flag. No return value.
11 | }
12 | \description{
13 | The \code{delete} function will remove an observation
14 | from the output of a datastep. The function takes no parameters. To use
15 | the function, simply call it on the rows you want to delete. Typically
16 | it is called within a conditional.
17 | }
18 | \examples{
19 | #' # Remove all cars that are not 4 cylinder
20 | df <- datastep(mtcars,
21 | keep = c("mpg", "cyl", "disp"), {
22 |
23 | if (cyl != 4)
24 | delete()
25 |
26 | })
27 |
28 | df
29 | # mpg cyl disp
30 | # 1 22.8 4 108.0
31 | # 2 24.4 4 146.7
32 | # 3 22.8 4 140.8
33 | # 4 32.4 4 78.7
34 | # 5 30.4 4 75.7
35 | # 6 33.9 4 71.1
36 | # 7 21.5 4 120.1
37 | # 8 27.3 4 79.0
38 | # 9 26.0 4 120.3
39 | # 10 30.4 4 95.1
40 | # 11 21.4 4 121.0
41 | }
42 | \seealso{
43 | Other datastep:
44 | \code{\link{[.dsarray}()},
45 | \code{\link{datastep}()},
46 | \code{\link{dsarray}()},
47 | \code{\link{dsattr}()},
48 | \code{\link{length.dsarray}()},
49 | \code{\link{output}()}
50 | }
51 | \concept{datastep}
52 |
--------------------------------------------------------------------------------
/_pkgdown.yml:
--------------------------------------------------------------------------------
1 | url: https://libr.r-sassy.org
2 |
3 | articles:
4 | - title: Examples
5 | navbar: ~
6 | contents:
7 | - libr-basics
8 | - libr-management
9 | - libr-datastep
10 | - libr-disclaimer
11 | - libr-example1
12 | - libr-example2
13 | - libr-faq
14 |
15 | reference:
16 | - title: Library Functions
17 | desc: Functions to create and manage data libraries.
18 | contents:
19 | - libname
20 | - lib_load
21 | - lib_unload
22 | - lib_sync
23 | - lib_write
24 | - lib_add
25 | - lib_replace
26 | - lib_remove
27 | - lib_copy
28 | - lib_export
29 | - lib_delete
30 | - lib_info
31 | - lib_path
32 | - lib_size
33 | - is.lib
34 | - print.lib
35 | - title: Library Specs Functions
36 | desc: Functions to create, read, and write import specs.
37 | contents:
38 | - specs
39 | - import_spec
40 | - write.specs
41 | - read.specs
42 | - print.specs
43 | - title: Datastep Functions
44 | desc: Functions to perform and enhance a datastep.
45 | contents:
46 | - datastep
47 | - dsattr
48 | - dsarray
49 | - "[.dsarray"
50 | - length.dsarray
51 | - delete
52 | - output
53 |
54 | - title: Other Functions
55 | desc: Other useful functions in the libr package.
56 | contents:
57 | - dictionary
58 |
59 | navbar:
60 | type: inverse
61 | structure:
62 | right: [home, intro, articles, reference, faq, news, github]
63 | left: []
64 | components:
65 | faq:
66 | text: FAQ
67 | href: ./articles/libr-faq.html
68 |
--------------------------------------------------------------------------------
/DESCRIPTION:
--------------------------------------------------------------------------------
1 | Package: libr
2 | Type: Package
3 | Title: Libraries, Data Dictionaries, and a Data Step for R
4 | Version: 1.3.9
5 | Maintainer: David Bosak
6 | Authors@R: c(
7 | person("David", "Bosak", email = "dbosak01@gmail.com", role = c("aut", "cre")),
8 | person("Brian", "Varney", email = "brian.varney@experis.com", role = "ctb"),
9 | person("Archytas Clinical Solutions", role = "cph")
10 | )
11 | Description: Contains a set of functions to create data libraries,
12 | generate data dictionaries, and simulate a data step.
13 | The libname() function will load a directory of data into
14 | a library in one line of code. The dictionary() function
15 | will generate data dictionaries for individual
16 | data frames or an entire library. And the datestep() function
17 | will perform row-by-row data processing.
18 | License: CC0
19 | Encoding: UTF-8
20 | URL: https://libr.r-sassy.org, https://github.com/dbosak01/libr
21 | BugReports: https://github.com/dbosak01/libr/issues
22 | Depends: R (>= 3.6.0),
23 | common (>= 1.1.0)
24 | Suggests:
25 | testthat,
26 | knitr,
27 | rmarkdown,
28 | foreign,
29 | magrittr,
30 | utils,
31 | logr,
32 | covr,
33 | fmtr,
34 | nanoparquet
35 | Imports:
36 | readr,
37 | readxl,
38 | haven,
39 | openxlsx,
40 | crayon,
41 | dplyr,
42 | tibble,
43 | tools,
44 | Rcpp,
45 | data.table
46 | RoxygenNote: 7.3.3
47 | VignetteBuilder: knitr
48 | LinkingTo:
49 | Rcpp
50 |
--------------------------------------------------------------------------------
/man/images/archive/books.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/man/lib_info.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/libname.R
3 | \name{lib_info}
4 | \alias{lib_info}
5 | \title{Get Information about a Data Library}
6 | \usage{
7 | lib_info(x)
8 | }
9 | \arguments{
10 | \item{x}{The data library.}
11 | }
12 | \value{
13 | A data frame of information about the library.
14 | }
15 | \description{
16 | The \code{lib_info} function returns a data frame of information
17 | about each item in the data library. That information includes the item
18 | name, file extension, number of rows, number of columns, size in bytes,
19 | and the last modified date.
20 | }
21 | \examples{
22 | # Create temp directory
23 | tmp <- tempdir()
24 |
25 | # Create data library
26 | libname(dat, tmp)
27 |
28 | # Add data to library
29 | lib_add(dat, trees, rock, beaver1)
30 |
31 | # Get library information
32 | info <- lib_info(dat)
33 |
34 | # Examine info
35 | info
36 | # Name Extension Rows Cols Size LastModified
37 | # 1 beaver1 rds 114 4 5.3 Kb 2020-11-05 21:27:57
38 | # 2 rocks rds 48 4 3.1 Kb 2020-11-05 21:27:56
39 | # 3 trees rds 31 3 2.4 Kb 2020-11-05 21:27:56
40 |
41 | # Clean up
42 | lib_delete(dat)
43 | }
44 | \seealso{
45 | Other lib:
46 | \code{\link{is.lib}()},
47 | \code{\link{lib_add}()},
48 | \code{\link{lib_copy}()},
49 | \code{\link{lib_delete}()},
50 | \code{\link{lib_export}()},
51 | \code{\link{lib_load}()},
52 | \code{\link{lib_path}()},
53 | \code{\link{lib_remove}()},
54 | \code{\link{lib_replace}()},
55 | \code{\link{lib_size}()},
56 | \code{\link{lib_sync}()},
57 | \code{\link{lib_unload}()},
58 | \code{\link{lib_write}()},
59 | \code{\link{libname}()},
60 | \code{\link{print.lib}()}
61 | }
62 | \concept{lib}
63 |
--------------------------------------------------------------------------------
/docs/man/images/archive/books.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/R/experiments.R:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | #' @noRd
6 | ds_experiment <- function() {
7 |
8 |
9 | dat <- mtcars
10 |
11 | cnt <- 0
12 |
13 | code <- expression(fork <- mpg / cyl,
14 | cnt <- cnt + 1)
15 |
16 |
17 | within(dat, eval(code), keepAttrs = TRUE)
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | l <- 100000
26 |
27 | df <- tibble(C1 = seq_len(l), C2 = runif(l),
28 | C3 = runif(l), C4 = runif(l))
29 |
30 | tm <- Sys.time()
31 |
32 | env <- new.env()
33 |
34 | env$n. <- 1
35 | #
36 | # res <- datastep(df, attrib = list(C5 = 0, C6 = 0),
37 | # {
38 | # C5 <- C2 + C3 + C4
39 | # C6 <- max(C2, C3, C4)
40 | # n. <- n. + 1
41 | # })
42 |
43 | n. <- 0
44 |
45 | exp <- expression(C5 <- C2 + C3 + C4,
46 | C6 <- max(C2, C3, C4),
47 |
48 | cnt <- n.)
49 |
50 |
51 | d2 <- within(df, eval(exp))
52 |
53 | d2
54 |
55 | d3 <- within(df, {C5 <- C2 + C3 + C4
56 | C6 <- max(C2, C3, C4)
57 | assign("n.", get("n.", envir = parent.frame(3)) + 1, envir = parent.frame(3))
58 | cnt <- get("n.", envir = parent.frame(3))})
59 |
60 | d3
61 |
62 |
63 |
64 | tmdiff <- Sys.time() - tm
65 | tmdiff
66 |
67 |
68 | mydat <- data.frame(A = c(1, 2, 3, 4),
69 | B = c(5, 6, 7, 8))
70 |
71 |
72 | myfunc <- function(dat) {
73 |
74 | retainedvar <- 1
75 |
76 | innerfunc <- Vectorize(function(dat){
77 |
78 | retainedvar <<- retainedvar + 1
79 | }
80 | )
81 |
82 | }
83 |
84 | # Base R
85 | lapply()
86 | mapply()
87 | sapply()
88 | vapply()
89 |
90 | # fmtr package
91 | fapply()
92 |
93 | subset(mtcars, mpg > 25)
94 |
95 | mtcars[mtcars$mpg > 25, ]
96 |
97 | }
98 |
--------------------------------------------------------------------------------
/man/print.lib.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/utilities.R
3 | \name{print.lib}
4 | \alias{print.lib}
5 | \title{Print a data library}
6 | \usage{
7 | \method{print}{lib}(x, ..., verbose = FALSE)
8 | }
9 | \arguments{
10 | \item{x}{The library to print.}
11 |
12 | \item{...}{Any follow-on parameters.}
13 |
14 | \item{verbose}{Whether or not to print the library in verbose style.
15 | By default, the parameter is FALSE, meaning to print in summary style.}
16 | }
17 | \value{
18 | The object, invisibly.
19 | }
20 | \description{
21 | A class-specific instance of the \code{print} function for
22 | data libraries. The function prints the library in a summary manner.
23 | Use \code{verbose = TRUE} to print the library as a list.
24 | }
25 | \examples{
26 | # Create temp directory
27 | tmp <- tempdir()
28 |
29 | # Create data library
30 | libname(dat, tmp)
31 |
32 | # Add data to library
33 | lib_add(dat, iris, ToothGrowth, PlantGrowth)
34 |
35 | # Print library summary
36 | print(dat)
37 | # library 'dat': 3 items
38 | # - attributes: not loaded
39 | # - path: C:\Users\User\AppData\Local\Temp\RtmpCSJ6Gc
40 | # - items:
41 | # Name Extension Rows Cols Size LastModified
42 | # 1 iris rds 150 5 7.8 Kb 2020-11-05 22:26:59
43 | # 2 PlantGrowth rds 30 2 2.5 Kb 2020-11-05 22:26:59
44 | # 3 ToothGrowth rds 60 3 3.4 Kb 2020-11-05 22:26:59
45 |
46 | # Clean up
47 | lib_delete(dat)
48 | }
49 | \seealso{
50 | Other lib:
51 | \code{\link{is.lib}()},
52 | \code{\link{lib_add}()},
53 | \code{\link{lib_copy}()},
54 | \code{\link{lib_delete}()},
55 | \code{\link{lib_export}()},
56 | \code{\link{lib_info}()},
57 | \code{\link{lib_load}()},
58 | \code{\link{lib_path}()},
59 | \code{\link{lib_remove}()},
60 | \code{\link{lib_replace}()},
61 | \code{\link{lib_size}()},
62 | \code{\link{lib_sync}()},
63 | \code{\link{lib_unload}()},
64 | \code{\link{lib_write}()},
65 | \code{\link{libname}()}
66 | }
67 | \concept{lib}
68 |
--------------------------------------------------------------------------------
/.github/workflows/R-CMD-check.yaml:
--------------------------------------------------------------------------------
1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3 | #
4 | # NOTE: This workflow is overkill for most R packages and
5 | # check-standard.yaml is likely a better choice.
6 | # usethis::use_github_action("check-standard") will install it.
7 | on:
8 | push:
9 | branches: [main, master]
10 | pull_request:
11 | branches: [main, master]
12 |
13 | name: R-CMD-check
14 |
15 | jobs:
16 | R-CMD-check:
17 | runs-on: ${{ matrix.config.os }}
18 |
19 | name: ${{ matrix.config.os }} (${{ matrix.config.r }})
20 |
21 | strategy:
22 | fail-fast: false
23 | matrix:
24 | config:
25 | - {os: macos-latest, r: 'release'}
26 |
27 | - {os: windows-latest, r: 'release'}
28 |
29 | # use 4.1 to check with rtools40's older compiler
30 | - {os: windows-latest, r: '4.1'}
31 |
32 | - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
33 | - {os: ubuntu-latest, r: 'release'}
34 | - {os: ubuntu-latest, r: 'oldrel-1'}
35 | - {os: ubuntu-latest, r: 'oldrel-2'}
36 | - {os: ubuntu-latest, r: 'oldrel-3'}
37 | - {os: ubuntu-latest, r: 'oldrel-4'}
38 |
39 | env:
40 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
41 | R_KEEP_PKG_SOURCE: yes
42 |
43 | steps:
44 | - uses: actions/checkout@v3
45 |
46 | - uses: r-lib/actions/setup-pandoc@v2
47 |
48 | - uses: r-lib/actions/setup-r@v2
49 | with:
50 | r-version: ${{ matrix.config.r }}
51 | http-user-agent: ${{ matrix.config.http-user-agent }}
52 | use-public-rspm: true
53 |
54 | - uses: r-lib/actions/setup-r-dependencies@v2
55 | with:
56 | extra-packages: any::rcmdcheck
57 | needs: check
58 |
59 | - uses: r-lib/actions/check-r-package@v2
60 | with:
61 | upload-snapshots: true
62 |
--------------------------------------------------------------------------------
/docs/bootstrap-toc.css:
--------------------------------------------------------------------------------
1 | /*!
2 | * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/)
3 | * Copyright 2015 Aidan Feldman
4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */
5 |
6 | /* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */
7 |
8 | /* All levels of nav */
9 | nav[data-toggle='toc'] .nav > li > a {
10 | display: block;
11 | padding: 4px 20px;
12 | font-size: 13px;
13 | font-weight: 500;
14 | color: #767676;
15 | }
16 | nav[data-toggle='toc'] .nav > li > a:hover,
17 | nav[data-toggle='toc'] .nav > li > a:focus {
18 | padding-left: 19px;
19 | color: #563d7c;
20 | text-decoration: none;
21 | background-color: transparent;
22 | border-left: 1px solid #563d7c;
23 | }
24 | nav[data-toggle='toc'] .nav > .active > a,
25 | nav[data-toggle='toc'] .nav > .active:hover > a,
26 | nav[data-toggle='toc'] .nav > .active:focus > a {
27 | padding-left: 18px;
28 | font-weight: bold;
29 | color: #563d7c;
30 | background-color: transparent;
31 | border-left: 2px solid #563d7c;
32 | }
33 |
34 | /* Nav: second level (shown on .active) */
35 | nav[data-toggle='toc'] .nav .nav {
36 | display: none; /* Hide by default, but at >768px, show it */
37 | padding-bottom: 10px;
38 | }
39 | nav[data-toggle='toc'] .nav .nav > li > a {
40 | padding-top: 1px;
41 | padding-bottom: 1px;
42 | padding-left: 30px;
43 | font-size: 12px;
44 | font-weight: normal;
45 | }
46 | nav[data-toggle='toc'] .nav .nav > li > a:hover,
47 | nav[data-toggle='toc'] .nav .nav > li > a:focus {
48 | padding-left: 29px;
49 | }
50 | nav[data-toggle='toc'] .nav .nav > .active > a,
51 | nav[data-toggle='toc'] .nav .nav > .active:hover > a,
52 | nav[data-toggle='toc'] .nav .nav > .active:focus > a {
53 | padding-left: 28px;
54 | font-weight: 500;
55 | }
56 |
57 | /* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */
58 | nav[data-toggle='toc'] .nav > .active > ul {
59 | display: block;
60 | }
61 |
--------------------------------------------------------------------------------
/man/lib_delete.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/libname.R
3 | \name{lib_delete}
4 | \alias{lib_delete}
5 | \title{Delete a Data Library}
6 | \usage{
7 | lib_delete(x)
8 | }
9 | \arguments{
10 | \item{x}{The data library to delete.}
11 | }
12 | \description{
13 | The \code{lib_delete} function deletes a data library from
14 | the file system and from memory. All data files associated with the library
15 | and the specified engine will be deleted.
16 | If other files exist in the library directory, they will not be affected
17 | by the delete operation.
18 |
19 | The directory that contains the data will also
20 | not be affected by the delete operation. To delete the data directory,
21 | use the \code{\link[base]{unlink}} function or other packaged functions.
22 | }
23 | \examples{
24 | # Create temp directory
25 | tmp <- tempdir()
26 |
27 | # Create library
28 | libname(dat, tmp)
29 |
30 | # Add data to library
31 | lib_add(dat, mtcars)
32 | lib_add(dat, iris)
33 |
34 | # Load library
35 | lib_load(dat)
36 |
37 | # Examine workspace
38 | ls()
39 | # [1] "dat" "dat.iris" "dat.mtcars" "tmp"
40 |
41 | # Examine library
42 | dat
43 | # library 'dat': 2 items
44 | # - attributes: not loaded
45 | # - path: C:\Users\User\AppData\Local\Temp\RtmpCSJ6Gc
46 | # - items:
47 | # Name Extension Rows Cols Size LastModified
48 | # 1 mtcars rds 32 11 7.5 Kb 2020-11-05 21:18:17
49 | # 2 iris rds 150 5 7.5 Kb 2020-11-05 21:18:17
50 |
51 | # Delete library
52 | lib_delete(dat)
53 |
54 | #' # Examine workspace again
55 | ls()
56 | # [1] "tmp"
57 | }
58 | \seealso{
59 | Other lib:
60 | \code{\link{is.lib}()},
61 | \code{\link{lib_add}()},
62 | \code{\link{lib_copy}()},
63 | \code{\link{lib_export}()},
64 | \code{\link{lib_info}()},
65 | \code{\link{lib_load}()},
66 | \code{\link{lib_path}()},
67 | \code{\link{lib_remove}()},
68 | \code{\link{lib_replace}()},
69 | \code{\link{lib_size}()},
70 | \code{\link{lib_sync}()},
71 | \code{\link{lib_unload}()},
72 | \code{\link{lib_write}()},
73 | \code{\link{libname}()},
74 | \code{\link{print.lib}()}
75 | }
76 | \concept{lib}
77 |
--------------------------------------------------------------------------------
/man/lib_remove.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/libname.R
3 | \name{lib_remove}
4 | \alias{lib_remove}
5 | \title{Remove Data from a Data Library}
6 | \usage{
7 | lib_remove(x, name)
8 | }
9 | \arguments{
10 | \item{x}{The data library.}
11 |
12 | \item{name}{The quoted name of the item to remove from the data library.
13 | For more than one name, pass a vector of quoted names.}
14 | }
15 | \value{
16 | The library with the requested item removed.
17 | }
18 | \description{
19 | The \code{lib_remove} function removes an item from the
20 | data library, and deletes the source file for that data. If the library
21 | is loaded, it will also remove that item from the workspace environment.
22 | }
23 | \examples{
24 | # Create temp directory
25 | tmp <- tempdir()
26 |
27 | # Create library
28 | libname(dat, tmp)
29 |
30 | # Add data to the library
31 | lib_add(dat, mtcars, beaver1, iris)
32 | # library 'dat': 3 items
33 | # - attributes: not loaded
34 | # - path: C:\Users\User\AppData\Local\Temp\RtmpCSJ6Gc
35 | # - items:
36 | # Name Extension Rows Cols Size LastModified
37 | # 1 mtcars rds 32 11 7.5 Kb 2020-11-05 19:32:00
38 | # 2 beaver1 rds 114 4 5.1 Kb 2020-11-05 19:32:04
39 | # 3 iris rds 150 5 7.5 Kb 2020-11-05 19:32:08
40 |
41 | # Remove items from the library
42 | lib_remove(dat, c("beaver1", "iris"))
43 | # library 'dat': 1 items
44 | # - attributes: not loaded
45 | # - path: C:\Users\User\AppData\Local\Temp\RtmpCSJ6Gc
46 | # - items:
47 | # Name Extension Rows Cols Size LastModified
48 | # 1 mtcars rds 32 11 7.5 Kb 2020-11-05 19:32:40
49 |
50 | # Clean up
51 | lib_delete(dat)
52 | }
53 | \seealso{
54 | Other lib:
55 | \code{\link{is.lib}()},
56 | \code{\link{lib_add}()},
57 | \code{\link{lib_copy}()},
58 | \code{\link{lib_delete}()},
59 | \code{\link{lib_export}()},
60 | \code{\link{lib_info}()},
61 | \code{\link{lib_load}()},
62 | \code{\link{lib_path}()},
63 | \code{\link{lib_replace}()},
64 | \code{\link{lib_size}()},
65 | \code{\link{lib_sync}()},
66 | \code{\link{lib_unload}()},
67 | \code{\link{lib_write}()},
68 | \code{\link{libname}()},
69 | \code{\link{print.lib}()}
70 | }
71 | \concept{lib}
72 |
--------------------------------------------------------------------------------
/R/libr.R:
--------------------------------------------------------------------------------
1 | #' @title Libnames, Data Dictionaries and Data Steps
2 | #'
3 | #' @description
4 | #' The \strong{libr} package brings the concepts of data libraries, data
5 | #' dictionaries, and data steps to R. A data library is an object used to define
6 | #' and manage
7 | #' an entire directory of data files. A data dictionary is a data frame full
8 | #' of information about a data library, data frame, or tibble. And a data step
9 | #' allows row-by-row processing of data.
10 | #'
11 | #' The functions contained in the \strong{libr} package are as follows:
12 | #' \itemize{
13 | #' \item{\code{\link{libname}}: Creates a data library}
14 | #' \item{\code{\link{dictionary}}: Creates a data dictionary}
15 | #' \item{\code{\link{datastep}}: Perform row-by-row processing of data}
16 | #' \item{\code{\link{lib_load}}: Loads a library into the workspace}
17 | #' \item{\code{\link{lib_unload}}: Unloads a library from the workspace}
18 | #' \item{\code{\link{lib_sync}}: Synchronizes the workspace with the library
19 | #' list}
20 | #' \item{\code{\link{lib_write}}: Writes library data to the file system}
21 | #' \item{\code{\link{lib_add}}: Adds data to a library}
22 | #' \item{\code{\link{lib_replace}}: Replaces data in a library}
23 | #' \item{\code{\link{lib_remove}}: Removes data from a library}
24 | #' \item{\code{\link{lib_copy}}: Copies a data library}
25 | #' \item{\code{\link{lib_delete}}: Deletes a data library}
26 | #' \item{\code{\link{lib_info}}: Returns a data frame of information about the
27 | #' library}
28 | #' \item{\code{\link{lib_path}}: Returns the path of a data library}
29 | #' \item{\code{\link{lib_size}}: Returns the size of the data library in bytes}
30 | #' \item{\code{\link{import_spec}}: Defines an import spec for a specific file}
31 | #' \item{\code{\link{specs}}: Contains all the import specs for a library}
32 | #' }
33 | #' Note that the \strong{libr} package is intended to be used with small and
34 | #' medium-sized data sets. It is not recommended for big data, as big data
35 | #' requires very careful control over which data is or is not loaded into memory.
36 | #' The \strong{libr} package, on the other hand, tends to load all data into memory
37 | #' indiscriminately.
38 | #' @import common
39 | #' @aliases libr-package
40 | #' @keywords internal
41 | #' @name libr
42 | "_PACKAGE"
43 |
--------------------------------------------------------------------------------
/docs/docsearch.js:
--------------------------------------------------------------------------------
1 | $(function() {
2 |
3 | // register a handler to move the focus to the search bar
4 | // upon pressing shift + "/" (i.e. "?")
5 | $(document).on('keydown', function(e) {
6 | if (e.shiftKey && e.keyCode == 191) {
7 | e.preventDefault();
8 | $("#search-input").focus();
9 | }
10 | });
11 |
12 | $(document).ready(function() {
13 | // do keyword highlighting
14 | /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */
15 | var mark = function() {
16 |
17 | var referrer = document.URL ;
18 | var paramKey = "q" ;
19 |
20 | if (referrer.indexOf("?") !== -1) {
21 | var qs = referrer.substr(referrer.indexOf('?') + 1);
22 | var qs_noanchor = qs.split('#')[0];
23 | var qsa = qs_noanchor.split('&');
24 | var keyword = "";
25 |
26 | for (var i = 0; i < qsa.length; i++) {
27 | var currentParam = qsa[i].split('=');
28 |
29 | if (currentParam.length !== 2) {
30 | continue;
31 | }
32 |
33 | if (currentParam[0] == paramKey) {
34 | keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20"));
35 | }
36 | }
37 |
38 | if (keyword !== "") {
39 | $(".contents").unmark({
40 | done: function() {
41 | $(".contents").mark(keyword);
42 | }
43 | });
44 | }
45 | }
46 | };
47 |
48 | mark();
49 | });
50 | });
51 |
52 | /* Search term highlighting ------------------------------*/
53 |
54 | function matchedWords(hit) {
55 | var words = [];
56 |
57 | var hierarchy = hit._highlightResult.hierarchy;
58 | // loop to fetch from lvl0, lvl1, etc.
59 | for (var idx in hierarchy) {
60 | words = words.concat(hierarchy[idx].matchedWords);
61 | }
62 |
63 | var content = hit._highlightResult.content;
64 | if (content) {
65 | words = words.concat(content.matchedWords);
66 | }
67 |
68 | // return unique words
69 | var words_uniq = [...new Set(words)];
70 | return words_uniq;
71 | }
72 |
73 | function updateHitURL(hit) {
74 |
75 | var words = matchedWords(hit);
76 | var url = "";
77 |
78 | if (hit.anchor) {
79 | url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor;
80 | } else {
81 | url = hit.url + '?q=' + escape(words.join(" "));
82 | }
83 |
84 | return url;
85 | }
86 |
--------------------------------------------------------------------------------
/man/lib_unload.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/libname.R
3 | \name{lib_unload}
4 | \alias{lib_unload}
5 | \title{Unload a Library from the Workspace}
6 | \usage{
7 | lib_unload(x, sync = TRUE, name = NULL)
8 | }
9 | \arguments{
10 | \item{x}{The data library to unload.}
11 |
12 | \item{sync}{Whether to sync the workspace with the library list before
13 | it is unloaded. Default is TRUE. If you want to unload the workspace
14 | without saving the workspace data, set this parameter to FALSE.}
15 |
16 | \item{name}{The name of the library to unload, if the name is different
17 | than the variable name. Used internally.}
18 | }
19 | \value{
20 | The unloaded data library.
21 | }
22 | \description{
23 | The \code{lib_unload} function unloads a data library from
24 | the workspace environment. The unload function does not delete the data
25 | or remove the library. It simply removes the data frames from working
26 | memory. By default, the \code{lib_unload} function will also synchronize the
27 | data in working memory with the data stored in the library list, as these
28 | two instances can become out of sync if you change the data in working memory.
29 | }
30 | \examples{
31 | # Create temp directory
32 | tmp <- tempdir()
33 |
34 | # Create library
35 | libname(dat, tmp)
36 |
37 | # Add data to library
38 | lib_add(dat, iris, ToothGrowth, PlantGrowth)
39 |
40 | # Load library into workspace
41 | lib_load(dat)
42 |
43 | # Examine workspace
44 | ls()
45 | # [1] "dat" "dat.iris" "dat.PlantGrowth" "dat.ToothGrowth" "tmp"
46 |
47 | # Use some data
48 | summary(dat.PlantGrowth)
49 | summary(dat.ToothGrowth)
50 |
51 | # Unload library
52 | lib_unload(dat)
53 |
54 | # Examine workspace again
55 | ls()
56 | # [1] "dat" "tmp"
57 |
58 | # Clean up
59 | lib_delete(dat)
60 | }
61 | \seealso{
62 | \code{\link{lib_load}} to load the library.
63 |
64 | Other lib:
65 | \code{\link{is.lib}()},
66 | \code{\link{lib_add}()},
67 | \code{\link{lib_copy}()},
68 | \code{\link{lib_delete}()},
69 | \code{\link{lib_export}()},
70 | \code{\link{lib_info}()},
71 | \code{\link{lib_load}()},
72 | \code{\link{lib_path}()},
73 | \code{\link{lib_remove}()},
74 | \code{\link{lib_replace}()},
75 | \code{\link{lib_size}()},
76 | \code{\link{lib_sync}()},
77 | \code{\link{lib_write}()},
78 | \code{\link{libname}()},
79 | \code{\link{print.lib}()}
80 | }
81 | \concept{lib}
82 |
--------------------------------------------------------------------------------
/src/RcppExports.cpp:
--------------------------------------------------------------------------------
1 | // Generated by using Rcpp::compileAttributes() -> do not edit by hand
2 | // Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
3 |
4 | #include
5 |
6 | using namespace Rcpp;
7 |
8 | #ifdef RCPP_USE_GLOBAL_ROSTREAM
9 | Rcpp::Rostream& Rcpp::Rcout = Rcpp::Rcpp_cout_get();
10 | Rcpp::Rostream& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get();
11 | #endif
12 |
13 | // bychanges
14 | CharacterVector bychanges(CharacterVector dat);
15 | RcppExport SEXP _libr_bychanges(SEXP datSEXP) {
16 | BEGIN_RCPP
17 | Rcpp::RObject rcpp_result_gen;
18 | Rcpp::RNGScope rcpp_rngScope_gen;
19 | Rcpp::traits::input_parameter< CharacterVector >::type dat(datSEXP);
20 | rcpp_result_gen = Rcpp::wrap(bychanges(dat));
21 | return rcpp_result_gen;
22 | END_RCPP
23 | }
24 | // byfirst
25 | LogicalVector byfirst(CharacterVector dat);
26 | RcppExport SEXP _libr_byfirst(SEXP datSEXP) {
27 | BEGIN_RCPP
28 | Rcpp::RObject rcpp_result_gen;
29 | Rcpp::RNGScope rcpp_rngScope_gen;
30 | Rcpp::traits::input_parameter< CharacterVector >::type dat(datSEXP);
31 | rcpp_result_gen = Rcpp::wrap(byfirst(dat));
32 | return rcpp_result_gen;
33 | END_RCPP
34 | }
35 | // bylast
36 | LogicalVector bylast(CharacterVector dat);
37 | RcppExport SEXP _libr_bylast(SEXP datSEXP) {
38 | BEGIN_RCPP
39 | Rcpp::RObject rcpp_result_gen;
40 | Rcpp::RNGScope rcpp_rngScope_gen;
41 | Rcpp::traits::input_parameter< CharacterVector >::type dat(datSEXP);
42 | rcpp_result_gen = Rcpp::wrap(bylast(dat));
43 | return rcpp_result_gen;
44 | END_RCPP
45 | }
46 | // getsigs
47 | RawVector getsigs(RawVector dat);
48 | RcppExport SEXP _libr_getsigs(SEXP datSEXP) {
49 | BEGIN_RCPP
50 | Rcpp::RObject rcpp_result_gen;
51 | Rcpp::RNGScope rcpp_rngScope_gen;
52 | Rcpp::traits::input_parameter< RawVector >::type dat(datSEXP);
53 | rcpp_result_gen = Rcpp::wrap(getsigs(dat));
54 | return rcpp_result_gen;
55 | END_RCPP
56 | }
57 |
58 | static const R_CallMethodDef CallEntries[] = {
59 | {"_libr_bychanges", (DL_FUNC) &_libr_bychanges, 1},
60 | {"_libr_byfirst", (DL_FUNC) &_libr_byfirst, 1},
61 | {"_libr_bylast", (DL_FUNC) &_libr_bylast, 1},
62 | {"_libr_getsigs", (DL_FUNC) &_libr_getsigs, 1},
63 | {NULL, NULL, 0}
64 | };
65 |
66 | RcppExport void R_init_libr(DllInfo *dll) {
67 | R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
68 | R_useDynamicSymbols(dll, FALSE);
69 | }
70 |
--------------------------------------------------------------------------------
/man/lib_add.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/libname.R
3 | \name{lib_add}
4 | \alias{lib_add}
5 | \title{Add Data to a Data Library}
6 | \usage{
7 | lib_add(x, ..., name = NULL)
8 | }
9 | \arguments{
10 | \item{x}{The library to add data to.}
11 |
12 | \item{...}{The data frame(s) to add to the library. If more than one,
13 | separate with commas.}
14 |
15 | \item{name}{The reference name to use for the data. By default,
16 | the name will be the variable name. To assign a name different
17 | from the variable name, assign a quoted name to this parameter. If more
18 | than one data set is being appended, assign a vector of quoted names.}
19 | }
20 | \description{
21 | The \code{\link{lib_add}} function adds a data frame
22 | or tibble to an existing data library. The function will both add the data
23 | to the library list, and immediately write the data to the library
24 | directory location. The data will be written to disk
25 | in the file format associated with the library engine.
26 | If the library is loaded, the function will also
27 | add the data to the workspace environment.
28 | }
29 | \examples{
30 | #' # Create temp directory
31 | tmp <- tempdir()
32 |
33 | # Create library
34 | libname(dat, tmp)
35 | # # library 'dat': 0 items
36 | # - attributes: rds not loaded
37 | # - path: C:\Users\User\AppData\Local\Temp\RtmpCSJ6Gc
38 | # NULL
39 |
40 | # Add data to the library
41 | lib_add(dat, mtcars, beaver1, iris)
42 | # library 'dat': 3 items
43 | # - attributes: not loaded
44 | # - path: C:\Users\User\AppData\Local\Temp\RtmpCSJ6Gc
45 | # - items:
46 | # Name Extension Rows Cols Size LastModified
47 | # 1 mtcars rds 32 11 7.5 Kb 2020-11-05 19:32:00
48 | # 2 beaver1 rds 114 4 5.1 Kb 2020-11-05 19:32:04
49 | # 3 iris rds 150 5 7.5 Kb 2020-11-05 19:32:08
50 |
51 | # Clean up
52 | lib_delete(dat)
53 | }
54 | \seealso{
55 | Other lib:
56 | \code{\link{is.lib}()},
57 | \code{\link{lib_copy}()},
58 | \code{\link{lib_delete}()},
59 | \code{\link{lib_export}()},
60 | \code{\link{lib_info}()},
61 | \code{\link{lib_load}()},
62 | \code{\link{lib_path}()},
63 | \code{\link{lib_remove}()},
64 | \code{\link{lib_replace}()},
65 | \code{\link{lib_size}()},
66 | \code{\link{lib_sync}()},
67 | \code{\link{lib_unload}()},
68 | \code{\link{lib_write}()},
69 | \code{\link{libname}()},
70 | \code{\link{print.lib}()}
71 | }
72 | \concept{lib}
73 |
--------------------------------------------------------------------------------
/man/lib_replace.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/libname.R
3 | \name{lib_replace}
4 | \alias{lib_replace}
5 | \title{Replace Data in a Data Library}
6 | \usage{
7 | lib_replace(x, ..., name = NULL)
8 | }
9 | \arguments{
10 | \item{x}{The library to replace data in.}
11 |
12 | \item{...}{The data frame(s) to replace. If you wish to replace more than
13 | one data set, separate with commas.}
14 |
15 | \item{name}{The reference name to use for the data. By default,
16 | the name will be the variable name. To assign a name different
17 | from the variable name, assign a quoted name to this parameter. If more
18 | than one data set is being replaced, assign a vector of quoted names.}
19 | }
20 | \description{
21 | The \code{\link{lib_replace}} function replaces a data frame
22 | in an existing data library. The function will replace the data
23 | in the library list, the data in the workspace (if loaded),
24 | and immediately write the new data to the library
25 | directory location. The data will be written in the file format
26 | associated with the library engine.
27 | }
28 | \examples{
29 | #' # Create temp directory
30 | tmp <- tempdir()
31 |
32 | # Create library
33 | libname(dat, tmp)
34 |
35 | # Add data to the library
36 | lib_add(dat, mtcars)
37 | # library 'dat': 3 items
38 | # - attributes: not loaded
39 | # - path: C:\Users\User\AppData\Local\Temp\RtmpCSJ6Gc
40 | # - items:
41 | # Name Extension Rows Cols Size LastModified
42 | # 1 mtcars rds 32 11 7.5 Kb 2020-11-05 19:32:00
43 |
44 | # Replace data with a subset
45 | lib_replace(dat, mtcars[1:10, 1:5], name = "mtcars")
46 | # library 'dat': 3 items
47 | # - attributes: not loaded
48 | # - path: C:\Users\User\AppData\Local\Temp\RtmpCSJ6Gc
49 | # - items:
50 | # Name Extension Rows Cols Size LastModified
51 | # 1 mtcars rds 10 5 7.5 Kb 2020-11-05 19:33:00
52 |
53 | # Clean up
54 | lib_delete(dat)
55 | }
56 | \seealso{
57 | Other lib:
58 | \code{\link{is.lib}()},
59 | \code{\link{lib_add}()},
60 | \code{\link{lib_copy}()},
61 | \code{\link{lib_delete}()},
62 | \code{\link{lib_export}()},
63 | \code{\link{lib_info}()},
64 | \code{\link{lib_load}()},
65 | \code{\link{lib_path}()},
66 | \code{\link{lib_remove}()},
67 | \code{\link{lib_size}()},
68 | \code{\link{lib_sync}()},
69 | \code{\link{lib_unload}()},
70 | \code{\link{lib_write}()},
71 | \code{\link{libname}()},
72 | \code{\link{print.lib}()}
73 | }
74 | \concept{lib}
75 |
--------------------------------------------------------------------------------
/man/import_spec.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/specs.R
3 | \name{import_spec}
4 | \alias{import_spec}
5 | \title{Create an Import Specification}
6 | \usage{
7 | import_spec(..., na = NULL, trim_ws = NULL)
8 | }
9 | \arguments{
10 | \item{...}{Named pairs of column names and column data types.
11 | Available types are: 'guess', 'logical', 'character', 'integer', 'numeric',
12 | 'date', 'datetime', and 'time'. The date/time data types accept an optional
13 | input format. To supply the input format, append it after the data type
14 | following an equals sign, e.g.: 'date=\%d\%B\%Y' or
15 | 'datetime=\%d\%m\%Y \%H:\%M:\%S'. Default is NULL, meaning no column
16 | types are specified, and the function should make its best
17 | guess for each column.}
18 |
19 | \item{na}{A vector of values to be treated as NA. For example, the
20 | vector \code{c('', ' ')} will cause empty strings and single blanks to
21 | be converted to NA values. Default is NULL, meaning the value of the
22 | \code{na} parameter will be taken from the \code{\link{specs}} function.
23 | Any value supplied on the \code{import_spec} function will override the
24 | value from the \code{specs} function.}
25 |
26 | \item{trim_ws}{Whether or not to trim white space from the input data values.
27 | The default is NULL, meaning the value of the \code{trim_ws} parameter
28 | will be taken from the \code{\link{specs}} function. Any value supplied
29 | on the \code{import_spec} function will override the value from the
30 | \code{specs} function.}
31 | }
32 | \value{
33 | The import specification object.
34 | }
35 | \description{
36 | A function to create the import specifications for a
37 | particular data file. This information can be used on the
38 | \code{\link{libname}} function to correctly assign the data types for
39 | columns on imported data. The import specifications are defined as
40 | name/value pairs, where the name is the column name and the value is the
41 | data type indicator. Available data type indicators are
42 | 'guess', 'logical', 'character', 'integer', 'numeric',
43 | 'date', 'datetime', and 'time'. See the \code{\link{specs}} function
44 | for an example of using import specs.
45 | }
46 | \seealso{
47 | \code{\link{libname}} to create a data library, and
48 | \code{\link{specs}} for an example using import specs.
49 |
50 | Other specs:
51 | \code{\link{print.specs}()},
52 | \code{\link{read.specs}()},
53 | \code{\link{specs}()},
54 | \code{\link{write.specs}()}
55 | }
56 | \concept{specs}
57 |
--------------------------------------------------------------------------------
/man/lib_copy.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/libname.R
3 | \name{lib_copy}
4 | \alias{lib_copy}
5 | \title{Copy a Data Library}
6 | \usage{
7 | lib_copy(x, nm, directory_path, standard_eval = FALSE)
8 | }
9 | \arguments{
10 | \item{x}{The library to copy.}
11 |
12 | \item{nm}{The variable name to hold the new library.
13 | The parameter will assume non-standard
14 | (unquoted) evaluation unless the \code{standard_eval} parameter is set
15 | to TRUE.}
16 |
17 | \item{directory_path}{The path to copy the library to.}
18 |
19 | \item{standard_eval}{A TRUE or FALSE value which indicates whether to
20 | use standard (quoted) or non-standard (unquoted) evaluation on the
21 | \code{nm} parameter. Default is FALSE. Use this parameter if you want to
22 | pass the target library name in a variable.}
23 | }
24 | \value{
25 | The new library.
26 | }
27 | \description{
28 | The \code{lib_copy} function copies a data library. The
29 | function accepts a library and a destination path. If the destination
30 | path does not exist, the function will attempt to create it.
31 |
32 | Note that
33 | the copy will result in the current data in memory written to the new
34 | destination directory. If the library is loaded into the workspace,
35 | the workspace version will be considered the most current version, and
36 | that is the version that will be copied.
37 | }
38 | \examples{
39 | # Create temp directory
40 | tmp <- tempdir()
41 |
42 | # Create library
43 | libname(dat1, tmp)
44 |
45 | # Add dat to library
46 | lib_add(dat1, mtcars, iris)
47 |
48 | # Copy dat1 to dat2
49 | lib_copy(dat1, dat2, file.path(tmp, "copy"))
50 | # library 'dat2': 2 items
51 | # - attributes: not loaded
52 | # - path: C:\Users\User\AppData\Local\Temp\RtmpCSJ6Gc/copy
53 | # - items:
54 | # Name Extension Rows Cols Size LastModified
55 | # 1 mtcars rds 32 11 7.5 Kb 2020-11-05 21:14:54
56 | # 2 iris rds 150 5 7.5 Kb 2020-11-05 21:14:54
57 |
58 | # Clean up
59 | lib_delete(dat1)
60 | lib_delete(dat2)
61 | }
62 | \seealso{
63 | Other lib:
64 | \code{\link{is.lib}()},
65 | \code{\link{lib_add}()},
66 | \code{\link{lib_delete}()},
67 | \code{\link{lib_export}()},
68 | \code{\link{lib_info}()},
69 | \code{\link{lib_load}()},
70 | \code{\link{lib_path}()},
71 | \code{\link{lib_remove}()},
72 | \code{\link{lib_replace}()},
73 | \code{\link{lib_size}()},
74 | \code{\link{lib_sync}()},
75 | \code{\link{lib_unload}()},
76 | \code{\link{lib_write}()},
77 | \code{\link{libname}()},
78 | \code{\link{print.lib}()}
79 | }
80 | \concept{lib}
81 |
--------------------------------------------------------------------------------
/R/dshelpers.R:
--------------------------------------------------------------------------------
1 |
2 | #' A function to add automatic variables to a dataset
3 | #' @noRd
4 | add_autos <- function(df, groups = NULL, sort_check = FALSE) {
5 |
6 |
7 | if (!is.null(groups)) {
8 |
9 | # Concatenate multiple columns into a single vector separated by a pipe
10 | res <- apply(df[groups], MARGIN = 1,
11 | FUN = function(i) paste(i, collapse = "|"))
12 |
13 | # Perform sort check if requested
14 | if (sort_check) {
15 | firstvals <- bychanges(res)
16 | ddat <- unique(res)
17 |
18 | if (length(ddat) != length(firstvals)) {
19 | stop(paste("Input data is not sorted according to the 'by' variable",
20 | "parameter.\n Either sort the input data properly or",
21 | "set the sort_check parameter to FALSE."))
22 | }
23 |
24 | }
25 |
26 | # Clear out any names on input
27 | #names(res) <- NULL
28 |
29 | df[["first."]] <- byfirst(res)
30 | df[["last."]] <- bylast(res)
31 |
32 | # Add first and last for each by variable
33 | for (nm in groups) {
34 |
35 | df[[paste0("first.", nm)]] <- byfirst(df[[nm]])
36 | df[[paste0("last.", nm)]] <- bylast(df[[nm]])
37 |
38 | }
39 |
40 | } else {
41 |
42 | if (nrow(df) > 0) {
43 | df[["first."]] <- c(TRUE, rep(FALSE, times = nrow(df) - 1))
44 | df[["last."]] <- c(rep(FALSE, times = nrow(df) - 1), TRUE)
45 | }
46 |
47 | }
48 |
49 | if (nrow(df) > 0)
50 | df[["..delete"]] <- FALSE
51 | else {
52 |
53 |
54 |
55 | if (ncol(df) == 0) {
56 | df <- data.frame("..delete" = FALSE, stringsAsFactors = FALSE)
57 | } else {
58 | nms <- names(df)
59 |
60 | nlst <- list()
61 | for (nm in nms){
62 | nlst[[nm]] <- NA
63 | }
64 |
65 | nlst[["..delete"]] <- FALSE
66 | df <- as.data.frame(nlst, row.names = NULL, stringsAsFactors = FALSE)
67 |
68 | }
69 |
70 |
71 |
72 |
73 | }
74 |
75 |
76 | return(df)
77 |
78 | }
79 |
80 |
81 | remove_autos <- function(data, groups) {
82 |
83 | ret <- data
84 |
85 | ret[["first."]] <- NULL
86 | ret[["last."]] <- NULL
87 | ret[["..delete"]] <- NULL
88 |
89 | if (!is.null(groups)) {
90 | for (nm in groups) {
91 |
92 | ret[[paste0("first.", nm)]] <- NULL
93 | ret[[paste0("last.", nm)]] <- NULL
94 |
95 | }
96 | }
97 |
98 | return(ret)
99 | }
100 |
--------------------------------------------------------------------------------
/man/lib_load.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/libname.R
3 | \name{lib_load}
4 | \alias{lib_load}
5 | \title{Load a Library into the Workspace}
6 | \usage{
7 | lib_load(x, filter = NULL)
8 | }
9 | \arguments{
10 | \item{x}{The data library to load.}
11 |
12 | \item{filter}{One or more quoted strings to use as filters for the
13 | data names to load into the workspace. For more than one filter string,
14 | pass them as a vector of strings. The filter string can be a full or
15 | partial name. If using a partial name, use a wild-card character (*)
16 | to identify the missing portion. The match will be case-insensitive.}
17 | }
18 | \value{
19 | The loaded data library.
20 | }
21 | \description{
22 | The \code{lib_load} function loads a data library into
23 | an environment. The environment used is associated with the library at
24 | the time it is created with the \code{\link{libname}} function.
25 | When the \code{lib_load} function is called, the data frames/tibbles
26 | will be loaded with . syntax. Loading the data frames
27 | into the environment makes them easy to access and use in your program.
28 |
29 | Note that the \code{lib_load} function is optional, and calling the function
30 | is not needed to access data in the \code{libname}. You may also access
31 | data directly from the \code{libname} using the dollar sign ($) syntax.
32 | }
33 | \examples{
34 | # Create temp directory
35 | tmp <- tempdir()
36 |
37 | # Save some data to temp directory for illustration purposes
38 | saveRDS(iris, file.path(tmp, "iris.rds"))
39 | saveRDS(ToothGrowth, file.path(tmp, "ToothGrowth.rds"))
40 | saveRDS(PlantGrowth, file.path(tmp, "PlantGrowth.rds"))
41 |
42 | # Create library
43 | libname(dat, tmp)
44 |
45 | # Load library into workspace
46 | lib_load(dat)
47 |
48 | # Examine workspace
49 | ls()
50 | # [1] "dat" "dat.iris" "dat.PlantGrowth" "dat.ToothGrowth" "tmp"
51 |
52 | # Use some data
53 | summary(dat.PlantGrowth)
54 | summary(dat.ToothGrowth)
55 |
56 | # Unload library
57 | lib_unload(dat)
58 |
59 | # Examine workspace again
60 | ls()
61 | # [1] "dat" "tmp"
62 |
63 | # Clean up
64 | lib_delete(dat)
65 | }
66 | \seealso{
67 | \code{\link{lib_unload}} to unload the library.
68 |
69 | Other lib:
70 | \code{\link{is.lib}()},
71 | \code{\link{lib_add}()},
72 | \code{\link{lib_copy}()},
73 | \code{\link{lib_delete}()},
74 | \code{\link{lib_export}()},
75 | \code{\link{lib_info}()},
76 | \code{\link{lib_path}()},
77 | \code{\link{lib_remove}()},
78 | \code{\link{lib_replace}()},
79 | \code{\link{lib_size}()},
80 | \code{\link{lib_sync}()},
81 | \code{\link{lib_unload}()},
82 | \code{\link{lib_write}()},
83 | \code{\link{libname}()},
84 | \code{\link{print.lib}()}
85 | }
86 | \concept{lib}
87 |
--------------------------------------------------------------------------------
/man/lib_sync.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/libname.R
3 | \name{lib_sync}
4 | \alias{lib_sync}
5 | \title{Synchronize Loaded Library}
6 | \usage{
7 | lib_sync(x, name = NULL)
8 | }
9 | \arguments{
10 | \item{x}{The data library to synchronize.}
11 |
12 | \item{name}{The name of the library to sync if not the variable
13 | name. Used internally.}
14 | }
15 | \value{
16 | The synchronized data library.
17 | }
18 | \description{
19 | The \code{lib_sync} function synchronizes the data
20 | loaded into the working environment with the data stored
21 | in the library list. Synchronization is necessary only
22 | for libraries that have been loaded into the working environment.
23 | The function
24 | copies data from the working environment to the library
25 | list, overwriting any data in the list. The function is useful when
26 | you want to update the library list, but are not yet ready to
27 | unload the data from working memory.
28 |
29 | Note that the \code{lib_sync} function does not
30 | write any data to disk. Also note that the \code{lib_sync} function will
31 | not automatically remove any variables from the library list that
32 | have been removed from the workspace. To remove items from the library
33 | list, use the \code{\link{lib_remove}} function. To write data to
34 | disk, use the \code{\link{lib_write}} function.
35 | }
36 | \examples{
37 | # Create temp directory
38 | tmp <- tempdir()
39 |
40 | # Create library
41 | libname(dat, tmp)
42 | # library 'dat': 0 items
43 | # - attributes: not loaded
44 | # - path: C:\Users\User\AppData\Local\Temp\RtmpCSJ6Gc
45 | # NULL
46 |
47 | # Load the library
48 | lib_load(dat)
49 |
50 | # Add data to the workspace
51 | dat.mtcars <- mtcars
52 | dat.beaver1 <- beaver1
53 | dat.iris <- iris
54 |
55 | # Sync the library
56 | lib_sync(dat)
57 | # library 'dat': 3 items
58 | # - attributes: loaded
59 | # - path: C:\Users\User\AppData\Local\Temp\RtmpCSJ6Gc
60 | # - items:
61 | # Name Extension Rows Cols Size LastModified
62 | # 1 beaver1 NA 114 4 4.6 Kb
63 | # 2 iris NA 150 5 7.1 Kb
64 | # 3 mtcars NA 32 11 7 Kb
65 |
66 | # Clean up
67 | lib_delete(dat)
68 | }
69 | \seealso{
70 | Other lib:
71 | \code{\link{is.lib}()},
72 | \code{\link{lib_add}()},
73 | \code{\link{lib_copy}()},
74 | \code{\link{lib_delete}()},
75 | \code{\link{lib_export}()},
76 | \code{\link{lib_info}()},
77 | \code{\link{lib_load}()},
78 | \code{\link{lib_path}()},
79 | \code{\link{lib_remove}()},
80 | \code{\link{lib_replace}()},
81 | \code{\link{lib_size}()},
82 | \code{\link{lib_unload}()},
83 | \code{\link{lib_write}()},
84 | \code{\link{libname}()},
85 | \code{\link{print.lib}()}
86 | }
87 | \concept{lib}
88 |
--------------------------------------------------------------------------------
/man/libr.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/libr.R
3 | \docType{package}
4 | \name{libr}
5 | \alias{libr}
6 | \alias{libr-package}
7 | \title{Libnames, Data Dictionaries and Data Steps}
8 | \description{
9 | The \strong{libr} package brings the concepts of data libraries, data
10 | dictionaries, and data steps to R. A data library is an object used to define
11 | and manage
12 | an entire directory of data files. A data dictionary is a data frame full
13 | of information about a data library, data frame, or tibble. And a data step
14 | allows row-by-row processing of data.
15 |
16 | The functions contained in the \strong{libr} package are as follows:
17 | \itemize{
18 | \item{\code{\link{libname}}: Creates a data library}
19 | \item{\code{\link{dictionary}}: Creates a data dictionary}
20 | \item{\code{\link{datastep}}: Perform row-by-row processing of data}
21 | \item{\code{\link{lib_load}}: Loads a library into the workspace}
22 | \item{\code{\link{lib_unload}}: Unloads a library from the workspace}
23 | \item{\code{\link{lib_sync}}: Synchronizes the workspace with the library
24 | list}
25 | \item{\code{\link{lib_write}}: Writes library data to the file system}
26 | \item{\code{\link{lib_add}}: Adds data to a library}
27 | \item{\code{\link{lib_replace}}: Replaces data in a library}
28 | \item{\code{\link{lib_remove}}: Removes data from a library}
29 | \item{\code{\link{lib_copy}}: Copies a data library}
30 | \item{\code{\link{lib_delete}}: Deletes a data library}
31 | \item{\code{\link{lib_info}}: Returns a data frame of information about the
32 | library}
33 | \item{\code{\link{lib_path}}: Returns the path of a data library}
34 | \item{\code{\link{lib_size}}: Returns the size of the data library in bytes}
35 | \item{\code{\link{import_spec}}: Defines an import spec for a specific file}
36 | \item{\code{\link{specs}}: Contains all the import specs for a library}
37 | }
38 | Note that the \strong{libr} package is intended to be used with small and
39 | medium-sized data sets. It is not recommended for big data, as big data
40 | requires very careful control over which data is or is not loaded into memory.
41 | The \strong{libr} package, on the other hand, tends to load all data into memory
42 | indiscriminately.
43 | }
44 | \seealso{
45 | Useful links:
46 | \itemize{
47 | \item \url{https://libr.r-sassy.org}
48 | \item \url{https://github.com/dbosak01/libr}
49 | \item Report bugs at \url{https://github.com/dbosak01/libr/issues}
50 | }
51 |
52 | }
53 | \author{
54 | \strong{Maintainer}: David Bosak \email{dbosak01@gmail.com}
55 |
56 | Other contributors:
57 | \itemize{
58 | \item Brian Varney \email{brian.varney@experis.com} [contributor]
59 | \item Archytas Clinical Solutions [copyright holder]
60 | }
61 |
62 | }
63 | \keyword{internal}
64 |
--------------------------------------------------------------------------------
/man/dictionary.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/dictionary.R
3 | \name{dictionary}
4 | \alias{dictionary}
5 | \title{Create a Data Dictionary}
6 | \usage{
7 | dictionary(x)
8 | }
9 | \arguments{
10 | \item{x}{The input library, data frame, or tibble.}
11 | }
12 | \description{
13 | A function to create a data dictionary for a data frame,
14 | a tibble, or a data library. The function will generate a tibble of
15 | information about the data. The tibble will contain the following columns:
16 | \itemize{
17 | \item{\strong{Name:} The name of the data object.}
18 | \item{\strong{Column:} The name of the column.}
19 | \item{\strong{Class:} The class of the column.}
20 | \item{\strong{Label:} The value of the label attribute.}
21 | \item{\strong{Description:} A description applied to this column.}
22 | \item{\strong{Format:} The value of the format attribute.}
23 | \item{\strong{Width:} The value of the width attribute if any have been
24 | assigned.}
25 | \item{\strong{Justify:} The justification or alignment attribute value.}
26 | \item{\strong{Rows:} The number of data rows.}
27 | \item{\strong{NAs:} The number of NA values in this column.}
28 | \item{\strong{MaxChar:} The maximum character length of the
29 | values in this column with no padding.}
30 | }
31 | }
32 | \examples{
33 | # Create temp directory
34 | tmp <- tempdir()
35 |
36 | # Create library
37 | libname(dat, tmp)
38 |
39 | # Add data to the library
40 | lib_add(dat, beaver1)
41 | lib_add(dat, iris)
42 |
43 | # Examine the dictionary for the library
44 | dictionary(dat)
45 | # A tibble: 9 x 10
46 | # Name Column Class Label Description Format Width Justify Rows NAs MaxChar
47 | #
48 | # 1 beaver1 day numeric NA NA NA NA NA 114 0 3
49 | # 2 beaver1 time numeric NA NA NA NA NA 114 0 4
50 | # 3 beaver1 temp numeric NA NA NA NA NA 114 0 5
51 | # 4 beaver1 activ numeric NA NA NA NA NA 114 0 1
52 | # 5 iris Sepal.Length numeric NA NA NA NA NA 150 0 3
53 | # 6 iris Sepal.Width numeric NA NA NA NA NA 150 0 3
54 | # 7 iris Petal.Length numeric NA NA NA NA NA 150 0 3
55 | # 8 iris Petal.Width numeric NA NA NA NA NA 150 0 3
56 | # 9 iris Species factor NA NA NA NA NA 150 0 10
57 |
58 | # Clean up
59 | lib_delete(dat)
60 | }
61 | \seealso{
62 | \code{\link{libname}} to create a data library. Also
63 | see the \code{\link{dsattr}} function to set attributes for your
64 | dataset from within a \code{\link{datastep}}. To render attributes,
65 | see the \strong{fmtr} package.
66 | }
67 |
--------------------------------------------------------------------------------
/man/output.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/datastep.R
3 | \name{output}
4 | \alias{output}
5 | \title{Outputs an observation from a datastep}
6 | \usage{
7 | output()
8 | }
9 | \value{
10 | Observation is marked with a output flag. No return value.
11 | }
12 | \description{
13 | The \code{output} function will output an observation
14 | from a datastep. The function takes no parameters. To use
15 | the function, simply call it on the rows you want to output. Typically
16 | it is called within a conditional. The output function is interesting
17 | in that you can output multiple rows for the same input observation.
18 | }
19 | \examples{
20 | #' # Example 1: Output all cars that are 4 cylinder
21 | df <- datastep(mtcars,
22 | keep = c("mpg", "cyl", "disp"), {
23 |
24 | if (cyl == 4)
25 | output()
26 |
27 | })
28 |
29 | df
30 | # mpg cyl disp
31 | # 1 22.8 4 108.0
32 | # 2 24.4 4 146.7
33 | # 3 22.8 4 140.8
34 | # 4 32.4 4 78.7
35 | # 5 30.4 4 75.7
36 | # 6 33.9 4 71.1
37 | # 7 21.5 4 120.1
38 | # 8 27.3 4 79.0
39 | # 9 26.0 4 120.3
40 | # 10 30.4 4 95.1
41 | # 11 21.4 4 121.0
42 |
43 | # Example 2: Output two rows for each 6 cylinder car
44 |
45 | # Prepare sample data
46 | dat <- data.frame(name = rownames(mtcars), mtcars, stringsAsFactors = FALSE)
47 |
48 | # Perform datastep
49 | df <- datastep(dat,
50 | keep = c("name", "mpg", "cyl", "disp", "seq"), {
51 |
52 | if (cyl == 6) {
53 | seq <- 1
54 | output()
55 | seq <- 2
56 | output()
57 | }
58 |
59 | })
60 |
61 | df
62 | # name mpg cyl disp seq
63 | # 1 Mazda RX4 21.0 6 160.0 1
64 | # 2 Mazda RX4 21.0 6 160.0 2
65 | # 3 Mazda RX4 Wag 21.0 6 160.0 1
66 | # 4 Mazda RX4 Wag 21.0 6 160.0 2
67 | # 5 Hornet 4 Drive 21.4 6 258.0 1
68 | # 6 Hornet 4 Drive 21.4 6 258.0 2
69 | # 7 Valiant 18.1 6 225.0 1
70 | # 8 Valiant 18.1 6 225.0 2
71 | # 9 Merc 280 19.2 6 167.6 1
72 | # 10 Merc 280 19.2 6 167.6 2
73 | # 11 Merc 280C 17.8 6 167.6 1
74 | # 12 Merc 280C 17.8 6 167.6 2
75 | # 13 Ferrari Dino 19.7 6 145.0 1
76 | # 14 Ferrari Dino 19.7 6 145.0 2
77 |
78 | # Example 3: Create data frame using output() functions
79 | df <- datastep(data.frame(), {
80 |
81 | # Row 1
82 | COL1 <- 1
83 | COL2 <- "One"
84 | output()
85 |
86 | # Row 2
87 | COL1 <- 2
88 | COL2 <- "Two"
89 | output()
90 |
91 | })
92 |
93 | df
94 | # COL1 COL2
95 | # 1 1 One
96 | # 2 2 Two
97 | }
98 | \seealso{
99 | Other datastep:
100 | \code{\link{[.dsarray}()},
101 | \code{\link{datastep}()},
102 | \code{\link{delete}()},
103 | \code{\link{dsarray}()},
104 | \code{\link{dsattr}()},
105 | \code{\link{length.dsarray}()}
106 | }
107 | \concept{datastep}
108 |
--------------------------------------------------------------------------------
/man/lib_export.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/libname.R
3 | \name{lib_export}
4 | \alias{lib_export}
5 | \title{Export a Data Library}
6 | \usage{
7 | lib_export(x, nm, directory_path, engine, filter = NULL, standard_eval = FALSE)
8 | }
9 | \arguments{
10 | \item{x}{The library to export.}
11 |
12 | \item{nm}{The variable name to hold the new library.
13 | The parameter will assume non-standard
14 | (unquoted) evaluation unless the \code{standard_eval} parameter is set
15 | to TRUE.}
16 |
17 | \item{directory_path}{The path to export the library to.}
18 |
19 | \item{engine}{The name of the engine to use for the exported data.
20 | The engine name corresponds to the standard file extension
21 | of the data file type. Valid values are 'rds', 'Rdata', 'rda', 'sas7bdat',
22 | 'xpt', 'xls', 'xlsx', 'dbf', 'csv', and 'parquet'.}
23 |
24 | \item{filter}{A filter string to limit which datasets are exported.
25 | The filter parameter accepts wildcards.}
26 |
27 | \item{standard_eval}{A TRUE or FALSE value which indicates whether to
28 | use standard (quoted) or non-standard (unquoted) evaluation on the
29 | \code{nm} parameter. Default is FALSE. Use this parameter if you want to
30 | pass the target library name in a variable.}
31 | }
32 | \value{
33 | The newly exported library.
34 | }
35 | \description{
36 | The \code{lib_export} function exports a data library to
37 | another library with a different directory and file format. The
38 | function accepts a library to export, the new library name,
39 | a destination path, and an engine name.
40 | If the destination
41 | path does not exist, the function will attempt to create it.
42 |
43 | Note that
44 | the export will result in the current data in memory written to the new
45 | destination directory. If the library is loaded into the workspace,
46 | the workspace version will be considered the most current version, and
47 | that is the version that will be exported.
48 | }
49 | \examples{
50 | # Create temp directory
51 | tmp <- tempdir()
52 |
53 | # Create library
54 | libname(dat1, tmp)
55 |
56 | # Add dat to library
57 | lib_add(dat1, mtcars, iris)
58 |
59 | # Export dat1 to dat2
60 | lib_export(dat1, dat2, file.path(tmp, "export"), "rdata")
61 | # library 'dat2': 2 items
62 | # - attributes: rdata not loaded
63 | # - path: C:\Users\User\AppData\Local\Temp\Rtmp0Sq3kt/export
64 | # - items:
65 | # Name Extension Rows Cols Size LastModified
66 | # 1 mtcars rdata 32 11 8.1 Kb 2022-06-23 00:10:52
67 | # 2 iris rdata 150 5 8.1 Kb 2022-06-23 00:10:52
68 |
69 | # Clean up
70 | lib_delete(dat1)
71 | lib_delete(dat2)
72 | }
73 | \seealso{
74 | Other lib:
75 | \code{\link{is.lib}()},
76 | \code{\link{lib_add}()},
77 | \code{\link{lib_copy}()},
78 | \code{\link{lib_delete}()},
79 | \code{\link{lib_info}()},
80 | \code{\link{lib_load}()},
81 | \code{\link{lib_path}()},
82 | \code{\link{lib_remove}()},
83 | \code{\link{lib_replace}()},
84 | \code{\link{lib_size}()},
85 | \code{\link{lib_sync}()},
86 | \code{\link{lib_unload}()},
87 | \code{\link{lib_write}()},
88 | \code{\link{libname}()},
89 | \code{\link{print.lib}()}
90 | }
91 | \concept{lib}
92 |
--------------------------------------------------------------------------------
/man/sub-.dsarray.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/dsarray.R
3 | \encoding{UTF-8}
4 | \name{[.dsarray}
5 | \alias{[.dsarray}
6 | \title{Indexer for Data Step Array}
7 | \usage{
8 | \method{[}{dsarray}(x, i = NULL)
9 | }
10 | \arguments{
11 | \item{x}{The \code{\link{dsarray}} object.}
12 |
13 | \item{i}{The index of the datastep array item to return a value for.
14 | This index can be a column name or position in the array. It can also
15 | be a vector of column names or positions. If no index
16 | is supplied, a vector of all array values will be returned.}
17 | }
18 | \value{
19 | The value of the specified column for the current row in the
20 | datastep. If no index is supplied, a vector of all column values will
21 | be returned.
22 | }
23 | \description{
24 | A custom indexer for the Datastep Array. The indexer will
25 | return a value for all columns or a specified column. To
26 | access all columns, leave the indexer empty. Otherwise, specify the
27 | the column name(s) or number(s) to return data for. The indexer will
28 | always act upon the current row in the datastep.
29 | For additional details, see the \code{\link{dsarray}} function.
30 | }
31 | \examples{
32 | library(libr)
33 |
34 | # Create AirPassengers Data Frame
35 | df <- as.data.frame(t(matrix(AirPassengers, 12,
36 | dimnames = list(month.abb, seq(1949, 1960)))),
37 | stringsAsFactors = FALSE)
38 |
39 | # Use datastep array to get sums by quarter
40 | # Examine different ways of referencing data inside datastep
41 | dat <- datastep(df,
42 | keep = c("Q1", "Q2", "Q3", "Q4", "Tot"),
43 | arrays = list(months = dsarray(names(df))),
44 | {
45 |
46 | # Reference by column name
47 | Q1 <- Jan + Feb + Mar
48 |
49 | # Reference by array positions
50 | Q2 <- sum(months[4:6])
51 |
52 | # Reference by array names
53 | Q3 <- sum(months[c("Jul", "Aug", "Sep")])
54 |
55 | # Reference by row position
56 | Q4 <- rw$Oct + rw[["Nov"]] + rw[[12]]
57 |
58 | # Empty indexer returns all column values in array
59 | Tot <- sum(months[])
60 |
61 | })
62 |
63 | dat
64 | # Q1 Q2 Q3 Q4 Tot
65 | # 1949 362 385 432 341 1520
66 | # 1950 382 409 498 387 1676
67 | # 1951 473 513 582 474 2042
68 | # 1952 544 582 681 557 2364
69 | # 1953 628 707 773 592 2700
70 | # 1954 627 725 854 661 2867
71 | # 1955 742 854 1023 789 3408
72 | # 1956 878 1005 1173 883 3939
73 | # 1957 972 1125 1336 988 4421
74 | # 1958 1020 1146 1400 1006 4572
75 | # 1959 1108 1288 1570 1174 5140
76 | # 1960 1227 1468 1736 1283 5714
77 | }
78 | \seealso{
79 | Other datastep:
80 | \code{\link{datastep}()},
81 | \code{\link{delete}()},
82 | \code{\link{dsarray}()},
83 | \code{\link{dsattr}()},
84 | \code{\link{length.dsarray}()},
85 | \code{\link{output}()}
86 | }
87 | \concept{datastep}
88 |
--------------------------------------------------------------------------------
/man/lib_write.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/libname.R
3 | \name{lib_write}
4 | \alias{lib_write}
5 | \title{Write a Data Library to the File System}
6 | \usage{
7 | lib_write(x, force = FALSE)
8 | }
9 | \arguments{
10 | \item{x}{The data library to write.}
11 |
12 | \item{force}{Force writing each data file to disk, even if it has not
13 | changed.}
14 | }
15 | \value{
16 | The saved data library.
17 | }
18 | \description{
19 | The \code{lib_write} function writes the data library
20 | to the file system. The library will be written to the
21 | directory for which it was defined, and each data frame will be written
22 | in the format associated with the library data engine. See the
23 | \code{\link{libname}} function for further elaboration on the types
24 | of engines available, and the assumptions/limitations of each.
25 |
26 | By default, the \code{lib_write} function will not write data that has
27 | not changed. Prior to writing a file, \code{lib_write} will compare the
28 | data in memory to the data on disk. If there are differences in the data,
29 | the function will overwrite the version on disk. To override the default
30 | behavior, use the \code{force} option to force \code{lib_write} to write
31 | every data file to disk.
32 |
33 | Note that writing sas7bdat files to disk is not supported.
34 | }
35 | \examples{
36 | # Create temp directory
37 | tmp <- tempdir()
38 |
39 | # Create library
40 | libname(dat, tmp)
41 | # # library 'dat': 0 items
42 | # - attributes: rds not loaded
43 | # - path: C:\Users\User\AppData\Local\Temp\RtmpCSJ6Gc
44 | # NULL
45 |
46 | # Load the empty library
47 | lib_load(dat)
48 |
49 | # Add data to the library
50 | dat.mtcars <- mtcars
51 | dat.beaver1 <- beaver1
52 | dat.iris <- iris
53 |
54 | # Unload the library
55 | lib_unload(dat)
56 | # library 'dat': 3 items
57 | # - attributes: rds not loaded
58 | # - path: C:\Users\User\AppData\Local\Temp\RtmpCSJ6Gc
59 | # - items:
60 | # Name Extension Rows Cols Size LastModified
61 | # 1 beaver1 NA 114 4 4.6 Kb
62 | # 2 iris NA 150 5 7.1 Kb
63 | # 3 mtcars NA 32 11 7 Kb
64 |
65 | # Write the library to the file system
66 | lib_write(dat)
67 | # library 'dat': 3 items
68 | #- attributes: not loaded
69 | #- path: C:\Users\User\AppData\Local\Temp\RtmpCSJ6Gc
70 | #- items:
71 | # Name Extension Rows Cols Size LastModified
72 | #1 beaver1 rds 114 4 4.8 Kb 2020-11-05 20:47:16
73 | #2 iris rds 150 5 7.3 Kb 2020-11-05 20:47:16
74 | #3 mtcars rds 32 11 7.3 Kb 2020-11-05 20:47:16
75 |
76 | # Clean up
77 | lib_delete(dat)
78 | }
79 | \seealso{
80 | Other lib:
81 | \code{\link{is.lib}()},
82 | \code{\link{lib_add}()},
83 | \code{\link{lib_copy}()},
84 | \code{\link{lib_delete}()},
85 | \code{\link{lib_export}()},
86 | \code{\link{lib_info}()},
87 | \code{\link{lib_load}()},
88 | \code{\link{lib_path}()},
89 | \code{\link{lib_remove}()},
90 | \code{\link{lib_replace}()},
91 | \code{\link{lib_size}()},
92 | \code{\link{lib_sync}()},
93 | \code{\link{lib_unload}()},
94 | \code{\link{libname}()},
95 | \code{\link{print.lib}()}
96 | }
97 | \concept{lib}
98 |
--------------------------------------------------------------------------------
/docs/sitemap.xml:
--------------------------------------------------------------------------------
1 |
2 | https://libr.r-sassy.org/404.html
3 | https://libr.r-sassy.org/articles/index.html
4 | https://libr.r-sassy.org/articles/libr-basics.html
5 | https://libr.r-sassy.org/articles/libr-datastep.html
6 | https://libr.r-sassy.org/articles/libr-disclaimer.html
7 | https://libr.r-sassy.org/articles/libr-example1.html
8 | https://libr.r-sassy.org/articles/libr-example2.html
9 | https://libr.r-sassy.org/articles/libr-faq.html
10 | https://libr.r-sassy.org/articles/libr-management.html
11 | https://libr.r-sassy.org/articles/libr.html
12 | https://libr.r-sassy.org/authors.html
13 | https://libr.r-sassy.org/index.html
14 | https://libr.r-sassy.org/news/index.html
15 | https://libr.r-sassy.org/reference/datastep.html
16 | https://libr.r-sassy.org/reference/delete.html
17 | https://libr.r-sassy.org/reference/dictionary.html
18 | https://libr.r-sassy.org/reference/dsarray.html
19 | https://libr.r-sassy.org/reference/dsattr.html
20 | https://libr.r-sassy.org/reference/import_spec.html
21 | https://libr.r-sassy.org/reference/index.html
22 | https://libr.r-sassy.org/reference/is.lib.html
23 | https://libr.r-sassy.org/reference/length.dsarray.html
24 | https://libr.r-sassy.org/reference/libname.html
25 | https://libr.r-sassy.org/reference/libr.html
26 | https://libr.r-sassy.org/reference/lib_add.html
27 | https://libr.r-sassy.org/reference/lib_copy.html
28 | https://libr.r-sassy.org/reference/lib_delete.html
29 | https://libr.r-sassy.org/reference/lib_export.html
30 | https://libr.r-sassy.org/reference/lib_info.html
31 | https://libr.r-sassy.org/reference/lib_load.html
32 | https://libr.r-sassy.org/reference/lib_path.html
33 | https://libr.r-sassy.org/reference/lib_remove.html
34 | https://libr.r-sassy.org/reference/lib_replace.html
35 | https://libr.r-sassy.org/reference/lib_size.html
36 | https://libr.r-sassy.org/reference/lib_sync.html
37 | https://libr.r-sassy.org/reference/lib_unload.html
38 | https://libr.r-sassy.org/reference/lib_write.html
39 | https://libr.r-sassy.org/reference/output.html
40 | https://libr.r-sassy.org/reference/print.lib.html
41 | https://libr.r-sassy.org/reference/print.specs.html
42 | https://libr.r-sassy.org/reference/read.specs.html
43 | https://libr.r-sassy.org/reference/specs.html
44 | https://libr.r-sassy.org/reference/sub-.dsarray.html
45 | https://libr.r-sassy.org/reference/write.specs.html
46 |
47 |
48 |
--------------------------------------------------------------------------------
/src/dshelpers.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | using namespace Rcpp;
3 |
4 | // This is a simple example of exporting a C++ function to R. You can
5 | // source this function into an R session using the Rcpp::sourceCpp
6 | // function (or via the Source button on the editor toolbar). Learn
7 | // more about Rcpp at:
8 | //
9 | // http://www.rcpp.org/
10 | // http://adv-r.had.co.nz/Rcpp.html
11 | // http://gallery.rcpp.org/
12 | //
13 |
14 |
15 | // [[Rcpp::export]]
16 | CharacterVector bychanges(CharacterVector dat) {
17 |
18 | int n = dat.length();
19 | CharacterVector res(1);
20 | //int counter = 0;
21 |
22 | res[0] = dat[0];
23 |
24 | for(int i = 1; i < n; i++) {
25 |
26 | if (dat[i] != dat[i - 1]) {
27 | res.push_back(dat[i]);
28 | }
29 |
30 | }
31 |
32 | return res;
33 | }
34 |
35 |
36 | // [[Rcpp::export]]
37 | LogicalVector byfirst(CharacterVector dat) {
38 |
39 | int n = dat.length();
40 | LogicalVector res(n);
41 |
42 |
43 | res[0] = true;
44 |
45 | for(int i = 1; i < n; i++) {
46 |
47 | if (dat[i] == dat[i - 1]) {
48 | res[i] = false;
49 | } else {
50 |
51 | res[i] = true;
52 | }
53 |
54 | }
55 |
56 | return res;
57 | }
58 |
59 |
60 | // [[Rcpp::export]]
61 | LogicalVector bylast(CharacterVector dat) {
62 |
63 | int n = dat.length() - 1;
64 | LogicalVector res(n + 1);
65 |
66 | res[n] = true;
67 |
68 | for(int i = 0; i < n; i++) {
69 |
70 | if (dat[i] == dat[i + 1]) {
71 | res[i] = false;
72 | } else {
73 |
74 | res[i] = true;
75 | }
76 |
77 | }
78 |
79 | return res;
80 | }
81 |
82 |
83 | // [[Rcpp::export]]
84 | RawVector getsigs(RawVector dat) {
85 |
86 | int n = dat.length();
87 | int spos;
88 | int npos;
89 |
90 | spos = dat[0];
91 |
92 | for(int i = 1; i < n; i++) {
93 |
94 | npos = dat[i];
95 |
96 | spos = spos ^ npos;
97 |
98 | }
99 |
100 | RawVector ret(1);
101 |
102 | ret[0] = spos;
103 |
104 | return ret;
105 | }
106 |
107 | // getBitSignature <- function(x) {
108 | //
109 | // spos <- x[1]
110 | // for (i in seq(2, length(x))) {
111 | //
112 | // spos <- xor(spos, x[i])
113 | // }
114 | //
115 | // return(spos)
116 | // }
117 |
118 | // captureSignatures <- function(dat) {
119 | //
120 | // ret <- list()
121 | //
122 | // att <- attributes(dat)
123 | // for (nm in names(att)) {
124 | // if (!nm %in% c("class", "name"))
125 | // attr(dat, nm) <- NULL
126 | // }
127 | //
128 | // idat <- serialize(dat, connection = NULL)
129 | //
130 | // ret$Length <- length(idat)
131 | // ret$Hex <- getBitSignature(idat)
132 | //
133 | // return(ret)
134 | // }
135 |
136 |
137 |
138 |
139 | // You can include R code blocks in C++ files processed with sourceCpp
140 | // (useful for testing and development). The R code will be automatically
141 | // run after the compilation.
142 | //
143 |
144 | /*** R
145 |
146 |
147 | #bychanges(as.character(mtcars[["gear"]]))
148 |
149 | #inp <- mtcars[order(mtcars[["cyl"]]), ]
150 |
151 | #dat <- add_autos(inp, c("cyl"))
152 |
153 | #dat
154 |
155 | #paste(mtcars[["am"]], mtcars[["gear"]])
156 |
157 | #dat["first."] <- byfirst2(mtcars, c("am", "gear"))
158 |
159 | #dat["first."] <- byfirst(mtcars, "am")
160 | #dat["last."] <- bylast(mtcars, c("am"))
161 |
162 | #dat
163 |
164 | #
165 | # nrow(mtcars)
166 | # ncol(mtcars)
167 |
168 |
169 | */
170 |
--------------------------------------------------------------------------------
/man/dsarray.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/dsarray.R
3 | \encoding{UTF-8}
4 | \name{dsarray}
5 | \alias{dsarray}
6 | \title{Create a Data Step Array}
7 | \usage{
8 | dsarray(...)
9 | }
10 | \arguments{
11 | \item{...}{Column names to include as part of the datastep array. The
12 | names can be provided as quoted strings or a vector of strings.
13 | If names are provided as quoted strings, separate the strings with commas
14 | (i.e. \code{dsarray("col1", "col2", "col3")}).}
15 | }
16 | \value{
17 | The datastep array object.
18 | }
19 | \description{
20 | A data step array is an object that allows you to iterate
21 | across a set of columns inside a \code{\link{datastep}}. This structure is
22 | useful when you need to perform the same or similar operations on many columns.
23 | }
24 | \details{
25 | The datastep array has an indexer that allows you to access a particular
26 | column value. The indexer can be used within a for loop to iterate over
27 | the array. In this manner, you can place a set of conditions inside
28 | the for loop and run the same conditional logic on all the columns
29 | in the array.
30 |
31 | You can also use the datastep array with an empty indexer in vectorized
32 | functions like \code{\link[base]{sum}}, \code{\link[base]{mean}},
33 | and \code{\link[base]{max}}. The empty indexer will return all the
34 | values in the array for the current row.
35 | }
36 | \examples{
37 | library(libr)
38 |
39 | # Create AirPassengers Data Frame
40 | df <- as.data.frame(t(matrix(AirPassengers, 12,
41 | dimnames = list(month.abb, seq(1949, 1960)))),
42 | stringsAsFactors = FALSE)
43 |
44 | # Use datastep array to get year tot, mean, and top month
45 | dat <- datastep(df,
46 | arrays = list(months = dsarray(names(df))),
47 | attrib = list(Tot = 0, Mean = 0, Top = ""),
48 | drop = "mth",
49 | {
50 |
51 | Tot <- sum(months[])
52 | Mean <- mean(months[])
53 |
54 | for (mth in months) {
55 | if (months[mth] == max(months[])) {
56 | Top <- mth
57 | }
58 | }
59 |
60 | })
61 |
62 | dat
63 | # Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Tot Mean Top
64 | # 1949 112 118 132 129 121 135 148 148 136 119 104 118 1520 126.6667 Aug
65 | # 1950 115 126 141 135 125 149 170 170 158 133 114 140 1676 139.6667 Aug
66 | # 1951 145 150 178 163 172 178 199 199 184 162 146 166 2042 170.1667 Aug
67 | # 1952 171 180 193 181 183 218 230 242 209 191 172 194 2364 197.0000 Aug
68 | # 1953 196 196 236 235 229 243 264 272 237 211 180 201 2700 225.0000 Aug
69 | # 1954 204 188 235 227 234 264 302 293 259 229 203 229 2867 238.9167 Jul
70 | # 1955 242 233 267 269 270 315 364 347 312 274 237 278 3408 284.0000 Jul
71 | # 1956 284 277 317 313 318 374 413 405 355 306 271 306 3939 328.2500 Jul
72 | # 1957 315 301 356 348 355 422 465 467 404 347 305 336 4421 368.4167 Aug
73 | # 1958 340 318 362 348 363 435 491 505 404 359 310 337 4572 381.0000 Aug
74 | # 1959 360 342 406 396 420 472 548 559 463 407 362 405 5140 428.3333 Aug
75 | # 1960 417 391 419 461 472 535 622 606 508 461 390 432 5714 476.1667 Jul
76 | }
77 | \seealso{
78 | \code{\link{libname}} to create a data library, and
79 | \code{\link{dictionary}} for generating a data dictionary
80 |
81 | Other datastep:
82 | \code{\link{[.dsarray}()},
83 | \code{\link{datastep}()},
84 | \code{\link{delete}()},
85 | \code{\link{dsattr}()},
86 | \code{\link{length.dsarray}()},
87 | \code{\link{output}()}
88 | }
89 | \concept{datastep}
90 |
--------------------------------------------------------------------------------
/docs/pkgdown.js:
--------------------------------------------------------------------------------
1 | /* http://gregfranko.com/blog/jquery-best-practices/ */
2 | (function($) {
3 | $(function() {
4 |
5 | $('.navbar-fixed-top').headroom();
6 |
7 | $('body').css('padding-top', $('.navbar').height() + 10);
8 | $(window).resize(function(){
9 | $('body').css('padding-top', $('.navbar').height() + 10);
10 | });
11 |
12 | $('[data-toggle="tooltip"]').tooltip();
13 |
14 | var cur_path = paths(location.pathname);
15 | var links = $("#navbar ul li a");
16 | var max_length = -1;
17 | var pos = -1;
18 | for (var i = 0; i < links.length; i++) {
19 | if (links[i].getAttribute("href") === "#")
20 | continue;
21 | // Ignore external links
22 | if (links[i].host !== location.host)
23 | continue;
24 |
25 | var nav_path = paths(links[i].pathname);
26 |
27 | var length = prefix_length(nav_path, cur_path);
28 | if (length > max_length) {
29 | max_length = length;
30 | pos = i;
31 | }
32 | }
33 |
34 | // Add class to parent , and enclosing if in dropdown
35 | if (pos >= 0) {
36 | var menu_anchor = $(links[pos]);
37 | menu_anchor.parent().addClass("active");
38 | menu_anchor.closest("li.dropdown").addClass("active");
39 | }
40 | });
41 |
42 | function paths(pathname) {
43 | var pieces = pathname.split("/");
44 | pieces.shift(); // always starts with /
45 |
46 | var end = pieces[pieces.length - 1];
47 | if (end === "index.html" || end === "")
48 | pieces.pop();
49 | return(pieces);
50 | }
51 |
52 | // Returns -1 if not found
53 | function prefix_length(needle, haystack) {
54 | if (needle.length > haystack.length)
55 | return(-1);
56 |
57 | // Special case for length-0 haystack, since for loop won't run
58 | if (haystack.length === 0) {
59 | return(needle.length === 0 ? 0 : -1);
60 | }
61 |
62 | for (var i = 0; i < haystack.length; i++) {
63 | if (needle[i] != haystack[i])
64 | return(i);
65 | }
66 |
67 | return(haystack.length);
68 | }
69 |
70 | /* Clipboard --------------------------*/
71 |
72 | function changeTooltipMessage(element, msg) {
73 | var tooltipOriginalTitle=element.getAttribute('data-original-title');
74 | element.setAttribute('data-original-title', msg);
75 | $(element).tooltip('show');
76 | element.setAttribute('data-original-title', tooltipOriginalTitle);
77 | }
78 |
79 | if(ClipboardJS.isSupported()) {
80 | $(document).ready(function() {
81 | var copyButton = "";
82 |
83 | $("div.sourceCode").addClass("hasCopyButton");
84 |
85 | // Insert copy buttons:
86 | $(copyButton).prependTo(".hasCopyButton");
87 |
88 | // Initialize tooltips:
89 | $('.btn-copy-ex').tooltip({container: 'body'});
90 |
91 | // Initialize clipboard:
92 | var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', {
93 | text: function(trigger) {
94 | return trigger.parentNode.textContent.replace(/\n#>[^\n]*/g, "");
95 | }
96 | });
97 |
98 | clipboardBtnCopies.on('success', function(e) {
99 | changeTooltipMessage(e.trigger, 'Copied!');
100 | e.clearSelection();
101 | });
102 |
103 | clipboardBtnCopies.on('error', function() {
104 | changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy');
105 | });
106 | });
107 | }
108 | })(window.jQuery || window.$)
109 |
--------------------------------------------------------------------------------
/man/dsattr.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/dsattr.R
3 | \encoding{UTF-8}
4 | \name{dsattr}
5 | \alias{dsattr}
6 | \title{Assign Datastep Variable Attributes}
7 | \usage{
8 | dsattr(
9 | default = NA,
10 | label = NULL,
11 | description = NULL,
12 | width = NULL,
13 | format = NULL,
14 | justify = NULL,
15 | ...
16 | )
17 | }
18 | \arguments{
19 | \item{default}{The default value of the column. The default value can
20 | be any valid data value. Typical default
21 | values might be an empty string ("") or a zero (0). If no
22 | default value is specified, the column will be defaulted to NA.}
23 |
24 | \item{label}{The label to associate with this column. Accepts
25 | any string value. The label will appear as a column header on some
26 | data viewers and reporting packages.}
27 |
28 | \item{description}{A description for this column. Accepts any string
29 | value. The description is intended to be a longer explanation of the
30 | purpose or source of the variable.}
31 |
32 | \item{width}{The desired width for the column in number of characters.}
33 |
34 | \item{format}{The format associated with this column. See the
35 | \strong{fmtr} package for more information about formatting.}
36 |
37 | \item{justify}{The desired justification for the column. This parameter
38 | is normally used only for fixed-width, character columns. Valid values
39 | are 'left', 'right', 'center', and 'centre'.}
40 |
41 | \item{...}{Any other attributes you wish to assign to this column. Pass
42 | these additional attributes as a name/value pair.}
43 | }
44 | \value{
45 | The data step attributes object.
46 | }
47 | \description{
48 | An object to assign attributes
49 | to a column in a \code{\link{datastep}}. The parameters allow you
50 | to set the following attributes: 'class', 'label', 'description', 'width',
51 | 'justify', and 'format'. Any other desired attributes can be set
52 | with \code{...}.
53 |
54 | The attributes available in the \code{dsattr} class are closely aligned
55 | with those available on the \code{\link{dictionary}} object.
56 | }
57 | \examples{
58 | library(libr)
59 |
60 | # Create small sample dataframe
61 | dat <- mtcars[1:10, c("mpg", "cyl")]
62 |
63 | # Perform datastep and assign attributes
64 | dat1 <- datastep(dat,
65 | attrib = list(mpg = dsattr(label = "Miles Per Gallon"),
66 | cyl = dsattr(label = "Cylinders"),
67 | mpgcat = dsattr(label = "Fuel Efficiency")),
68 | {
69 |
70 | if (mpg >= 20)
71 | mpgcat = "High"
72 | else
73 | mpgcat = "Low"
74 |
75 | })
76 |
77 | # Print results
78 | dat1
79 | # mpg cyl mpgcat
80 | # Mazda RX4 21.0 6 High
81 | # Mazda RX4 Wag 21.0 6 High
82 | # Datsun 710 22.8 4 High
83 | # Hornet 4 Drive 21.4 6 High
84 | # Hornet Sportabout 18.7 8 Low
85 | # Valiant 18.1 6 Low
86 | # Duster 360 14.3 8 Low
87 | # Merc 240D 24.4 4 High
88 | # Merc 230 22.8 4 High
89 | # Merc 280 19.2 6 Low
90 |
91 | # Examine label attributes
92 | attr(dat1$mpg, "label")
93 | # [1] "Miles Per Gallon"
94 |
95 | attr(dat1$cyl, "label")
96 | # [1] "Cylinders"
97 |
98 | attr(dat1$mpgcat, "label")
99 | # [1] "Fuel Efficiency"
100 |
101 | # See labels in viewer
102 | # View(dat1)
103 | }
104 | \seealso{
105 | \code{\link{dictionary}} function to observe the attributes
106 | associated with a dataset. Also see the \code{fdata}
107 | function in the \strong{fmtr}
108 | package for more information on formatting and rendering data frames.
109 |
110 | Other datastep:
111 | \code{\link{[.dsarray}()},
112 | \code{\link{datastep}()},
113 | \code{\link{delete}()},
114 | \code{\link{dsarray}()},
115 | \code{\link{length.dsarray}()},
116 | \code{\link{output}()}
117 | }
118 | \concept{datastep}
119 |
--------------------------------------------------------------------------------
/tests/testthat/test-utilities.R:
--------------------------------------------------------------------------------
1 | context("Utilities Tests")
2 |
3 | base_path <- "c:\\packages\\libr\\tests\\testthat\\data"
4 |
5 | base_path <- "./data"
6 |
7 | DEV <- FALSE
8 |
9 | test_that("utils01: print() functions works as expected.", {
10 |
11 | if (DEV) {
12 |
13 | libname(dat, base_path, engine = "csv")
14 |
15 |
16 | dat
17 |
18 | expect_equal(is.lib(dat), TRUE)
19 |
20 | res <- capture.output(print(dat))
21 |
22 | expect_equal(length(res) > 0, TRUE)
23 |
24 |
25 | res2 <- capture.output(print(dat, verbose = TRUE))
26 |
27 | expect_equal(length(res2) > 0, TRUE)
28 |
29 | } else
30 | expect_equal(TRUE, TRUE)
31 |
32 | })
33 |
34 |
35 | test_that("utils02: dofilter function works as expected for paths", {
36 |
37 |
38 | v1 <- c("/temp/fork.csv", "/temp/four.csv", "/temp/spork.csv")
39 |
40 | expect_equal(dofilter("fo*", v1, "csv"), c("/temp/fork.csv", "/temp/four.csv"))
41 |
42 | expect_equal(dofilter("fork", v1, "csv"), c("/temp/fork.csv"))
43 |
44 | expect_equal(is.null(dofilter("or*", v1, "csv")), TRUE)
45 |
46 | expect_equal(dofilter("*or*", v1, "csv"), c("/temp/fork.csv","/temp/spork.csv"))
47 |
48 | expect_equal(dofilter(c("fo*", "sp*"), v1, "csv"), c("/temp/fork.csv",
49 | "/temp/four.csv",
50 | "/temp/spork.csv"))
51 |
52 | expect_equal(dofilter(c("Fo*", "SP*"), v1, "csv"), c("/temp/fork.csv",
53 | "/temp/four.csv",
54 | "/temp/spork.csv"))
55 |
56 | })
57 |
58 |
59 | test_that("utils03: dofilter function works as expected for names", {
60 |
61 |
62 | v2 <- c("fork", "four", "spork")
63 |
64 | expect_equal(dofilter("fo*", v2), c("fork", "four"))
65 |
66 | expect_equal(dofilter("fork", v2), c("fork"))
67 |
68 | expect_equal(is.null(dofilter("or*", v2)), TRUE)
69 |
70 | expect_equal(dofilter("*or*", v2), c("fork", "spork"))
71 |
72 | expect_equal(dofilter(c("fo*", "sp*"), v2), c("fork", "four", "spork"))
73 |
74 | expect_equal(dofilter(c("fork", "spork"), v2), c("fork", "spork"))
75 |
76 | expect_equal(dofilter(c("FORK", "Sp*"), v2), c("fork", "spork"))
77 |
78 | })
79 |
80 | test_that("utils04: copy_attributes function works as expected.", {
81 |
82 | d1 <- mtcars
83 | d2 <- mtcars
84 |
85 | attr(d1$mpg, "label") <- "Here1"
86 | attr(d1$disp, "label") <- "Here2"
87 |
88 | d3 <- copy_attributes(d1, d2)
89 |
90 | expect_equal(attr(d3$mpg, "label"), "Here1")
91 | expect_equal(attr(d3$disp, "label"), "Here2")
92 |
93 | })
94 |
95 |
96 | test_that("utils05: getExtension() works with two dots", {
97 |
98 | flnm <- "table_hemo.1.csv"
99 |
100 | res <- getExtension(flnm)
101 |
102 | expect_equal(length(res), 1)
103 | expect_equal(res, "csv")
104 |
105 |
106 | })
107 |
108 |
109 | test_that("utils06: getsignatures() works as expected.", {
110 |
111 | s1 <- serialize(iris, NULL)
112 |
113 |
114 | s1[1]
115 |
116 |
117 | m1 <- getBitSignature(s1)
118 | m2 <- getsigs(s1)
119 |
120 | m1
121 | m2
122 |
123 | expect_equal(m1 == m2, TRUE)
124 |
125 | })
126 |
127 | test_that("utils07: captureSignatures() works as expected.", {
128 |
129 |
130 | m1 <- mtcars
131 | m2 <- mtcars
132 | m3 <- mtcars
133 |
134 | m2[1, "carb"] <- 3
135 | attr(m3, "fork") <- 1
136 |
137 | s1 <- captureSignatures(m1)
138 | s2 <- captureSignatures(m2)
139 | s3 <- captureSignatures(m3)
140 |
141 | expect_equal(s1$Length == s2$Length, TRUE)
142 | expect_equal(s1$Hex == s2$Hex, FALSE)
143 | expect_equal(s1$Length == s3$Length, TRUE)
144 | expect_equal(s1$Hex == s3$Hex, TRUE)
145 |
146 | })
147 |
148 |
149 | #
150 | # test_that("libname() var_name parameter works as expected.", {
151 | #
152 | #
153 | #
154 | # expect_equal(standard_eval(), FALSE)
155 | #
156 | # options("libr.standard_eval" = TRUE)
157 | #
158 | # expect_equal(standard_eval(), TRUE)
159 | #
160 | # options("libr.standard_eval" = FALSE)
161 | #
162 | # expect_equal(standard_eval(), FALSE)
163 | #
164 | #
165 | #
166 | #
167 | # })
168 |
169 |
--------------------------------------------------------------------------------
/R/dsattr.R:
--------------------------------------------------------------------------------
1 |
2 | #' @title Assign Datastep Variable Attributes
3 | #' @encoding UTF-8
4 | #' @description An object to assign attributes
5 | #' to a column in a \code{\link{datastep}}. The parameters allow you
6 | #' to set the following attributes: 'class', 'label', 'description', 'width',
7 | #' 'justify', and 'format'. Any other desired attributes can be set
8 | #' with \code{...}.
9 | #'
10 | #' The attributes available in the \code{dsattr} class are closely aligned
11 | #' with those available on the \code{\link{dictionary}} object.
12 | #' @param default The default value of the column. The default value can
13 | #' be any valid data value. Typical default
14 | #' values might be an empty string ("") or a zero (0). If no
15 | #' default value is specified, the column will be defaulted to NA.
16 | #' @param label The label to associate with this column. Accepts
17 | #' any string value. The label will appear as a column header on some
18 | #' data viewers and reporting packages.
19 | #' @param description A description for this column. Accepts any string
20 | #' value. The description is intended to be a longer explanation of the
21 | #' purpose or source of the variable.
22 | #' @param width The desired width for the column in number of characters.
23 | #' @param format The format associated with this column. See the
24 | #' \strong{fmtr} package for more information about formatting.
25 | #' @param justify The desired justification for the column. This parameter
26 | #' is normally used only for fixed-width, character columns. Valid values
27 | #' are 'left', 'right', 'center', and 'centre'.
28 | #' @param ... Any other attributes you wish to assign to this column. Pass
29 | #' these additional attributes as a name/value pair.
30 | #' @return The data step attributes object.
31 | #' @seealso \code{\link{dictionary}} function to observe the attributes
32 | #' associated with a dataset. Also see the \code{fdata}
33 | #' function in the \strong{fmtr}
34 | #' package for more information on formatting and rendering data frames.
35 | #' @family datastep
36 | #' @examples
37 | #' library(libr)
38 | #'
39 | #' # Create small sample dataframe
40 | #' dat <- mtcars[1:10, c("mpg", "cyl")]
41 | #'
42 | #' # Perform datastep and assign attributes
43 | #' dat1 <- datastep(dat,
44 | #' attrib = list(mpg = dsattr(label = "Miles Per Gallon"),
45 | #' cyl = dsattr(label = "Cylinders"),
46 | #' mpgcat = dsattr(label = "Fuel Efficiency")),
47 | #' {
48 | #'
49 | #' if (mpg >= 20)
50 | #' mpgcat = "High"
51 | #' else
52 | #' mpgcat = "Low"
53 | #'
54 | #' })
55 | #'
56 | #' # Print results
57 | #' dat1
58 | #' # mpg cyl mpgcat
59 | #' # Mazda RX4 21.0 6 High
60 | #' # Mazda RX4 Wag 21.0 6 High
61 | #' # Datsun 710 22.8 4 High
62 | #' # Hornet 4 Drive 21.4 6 High
63 | #' # Hornet Sportabout 18.7 8 Low
64 | #' # Valiant 18.1 6 Low
65 | #' # Duster 360 14.3 8 Low
66 | #' # Merc 240D 24.4 4 High
67 | #' # Merc 230 22.8 4 High
68 | #' # Merc 280 19.2 6 Low
69 | #'
70 | #' # Examine label attributes
71 | #' attr(dat1$mpg, "label")
72 | #' # [1] "Miles Per Gallon"
73 | #'
74 | #' attr(dat1$cyl, "label")
75 | #' # [1] "Cylinders"
76 | #'
77 | #' attr(dat1$mpgcat, "label")
78 | #' # [1] "Fuel Efficiency"
79 | #'
80 | #' # See labels in viewer
81 | #' # View(dat1)
82 | #' @export
83 | dsattr <- function(default = NA, label = NULL, description = NULL,
84 | width = NULL, format = NULL,
85 | justify = NULL, ...) {
86 |
87 | # Create new structure of class "dsattr"
88 | s <- structure(list(), class = c("dsattr", "list"))
89 |
90 | # Assign parameters to class properties
91 | s$label <- label
92 | s$format <- format
93 | s$width <- width
94 | s$justify <- justify
95 | s$description <- description
96 | s$default <- default
97 |
98 | # Deal with ... custom attributes
99 | l <- list(...)
100 | for (nm in names(l)) {
101 | s[[nm]] <- l[[nm]]
102 | }
103 |
104 | return(s)
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | [](https://cran.r-project.org/package=libr)
4 | [](https://cran.r-project.org/package=libr)
5 | [](https://cran.r-project.org/package=libr)
6 | [](https://cran.r-project.org/package=libr)
7 | [](https://github.com/dbosak01/libr/actions/workflows/R-CMD-check.yaml)
8 | [](https://app.codecov.io/gh/dbosak01/libr?branch=master)
9 |
10 |
11 |
12 | # Introduction to **libr**
13 |
14 |
15 | R is a very flexible and powerful language. But there are some inconveniences
16 | when working with data:
17 |
18 | 1. **Loading many related datasets**: When you have many data files
19 | that are related in some way, it is troublesome when you want to use
20 | them all in your analysis. Most data import packages make you load each
21 | file individually. And the thing is, *almost all data* comes in sets of related
22 | files. So you would think that there would be an easy mechanism
23 | to load them all at once.
24 |
25 | 2. **Examining the Attributes of Your Data**: Once you have a set of related
26 | data files loaded into your program, the next problem is how to examine
27 | the structure of *all of them*. R has the `str()` function
28 | if you want to understand the structure of a single dataset. But what if
29 | there are many? There is no simple way to examine the attributes
30 | of many related datasets. And further, some valuable attributes are missing
31 | from the `str()` function output.
32 |
33 | 3. **Row-By-Row Processing of Data**: R processes data column by column.
34 | In most cases, column-by-column is a perfectly suitable way of processing data.
35 | But in some cases it is desirable to process data row-by-row. Row-by-row
36 | processing is useful when you have many related columns, and want to
37 | perform complex conditional processing across them. It is also very convenient
38 | when you have grouped data, and want to perform conditional processing
39 | within a group.
40 |
41 | ### Solution
42 |
43 | The **libr** package was developed to address all of the above problems. It does so
44 | by introducing three concepts:
45 |
46 | * Data Libraries
47 | * Data Dictionaries
48 | * A Data Step
49 |
50 | By introducing these concepts, the **libr** package makes working with
51 | data in R much easier and faster. The **libr** package can greatly simplify
52 | your data processing code. And it makes some types of data operations effortless
53 | that are quite tricky to do with **Base R** or even **tidyverse** functions.
54 |
55 | ### Installation
56 |
57 | To install the **libr** package, run the following
58 | command from your R console:
59 |
60 | install.packages("libr")
61 |
62 |
63 | Then put the following line at the top of your program or script:
64 |
65 | library(libr)
66 |
67 | The **libr** package will then be ready to use! For examples and usage
68 | information, please visit the **libr** documentation site
69 | [here](https://libr.r-sassy.org/articles/libr.html)
70 |
71 | ### Introductory Videos
72 |
73 | Here is a brief introduction to the concept of data libraries and how they
74 | are implemented in the **libr** package:
75 |
76 | [](https://www.youtube.com/watch?v=uHo8J9LR1xo)
77 |
78 |
79 | ### Getting Help
80 |
81 | If you need help, the first place
82 | to turn to is the [libr](https://libr.r-sassy.org) web site. The web site
83 | has full documentation on all **libr** functions.
84 |
85 | If you want to look at the code for the **libr** package, visit the
86 | github page [here](https://github.com/dbosak01/libr).
87 |
88 | If you encounter a bug or have a feature request, please submit an issue
89 | [here](https://github.com/dbosak01/libr/issues).
90 |
91 | ### See Also
92 |
93 | The **libr** package is part of the **sassy** meta-package.
94 | The **sassy** meta-package includes several packages that help make R
95 | easier for everyone, especially people with a background in SAS® software.
96 | You can read more about the **sassy** package
97 | [here](https://r-sassy.org/).
98 |
--------------------------------------------------------------------------------
/docs/bootstrap-toc.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/)
3 | * Copyright 2015 Aidan Feldman
4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */
5 | (function() {
6 | 'use strict';
7 |
8 | window.Toc = {
9 | helpers: {
10 | // return all matching elements in the set, or their descendants
11 | findOrFilter: function($el, selector) {
12 | // http://danielnouri.org/notes/2011/03/14/a-jquery-find-that-also-finds-the-root-element/
13 | // http://stackoverflow.com/a/12731439/358804
14 | var $descendants = $el.find(selector);
15 | return $el.filter(selector).add($descendants).filter(':not([data-toc-skip])');
16 | },
17 |
18 | generateUniqueIdBase: function(el) {
19 | var text = $(el).text();
20 | var anchor = text.trim().toLowerCase().replace(/[^A-Za-z0-9]+/g, '-');
21 | return anchor || el.tagName.toLowerCase();
22 | },
23 |
24 | generateUniqueId: function(el) {
25 | var anchorBase = this.generateUniqueIdBase(el);
26 | for (var i = 0; ; i++) {
27 | var anchor = anchorBase;
28 | if (i > 0) {
29 | // add suffix
30 | anchor += '-' + i;
31 | }
32 | // check if ID already exists
33 | if (!document.getElementById(anchor)) {
34 | return anchor;
35 | }
36 | }
37 | },
38 |
39 | generateAnchor: function(el) {
40 | if (el.id) {
41 | return el.id;
42 | } else {
43 | var anchor = this.generateUniqueId(el);
44 | el.id = anchor;
45 | return anchor;
46 | }
47 | },
48 |
49 | createNavList: function() {
50 | return $('');
51 | },
52 |
53 | createChildNavList: function($parent) {
54 | var $childList = this.createNavList();
55 | $parent.append($childList);
56 | return $childList;
57 | },
58 |
59 | generateNavEl: function(anchor, text) {
60 | var $a = $('');
61 | $a.attr('href', '#' + anchor);
62 | $a.text(text);
63 | var $li = $('');
64 | $li.append($a);
65 | return $li;
66 | },
67 |
68 | generateNavItem: function(headingEl) {
69 | var anchor = this.generateAnchor(headingEl);
70 | var $heading = $(headingEl);
71 | var text = $heading.data('toc-text') || $heading.text();
72 | return this.generateNavEl(anchor, text);
73 | },
74 |
75 | // Find the first heading level (``, then ``, etc.) that has more than one element. Defaults to 1 (for ``).
76 | getTopLevel: function($scope) {
77 | for (var i = 1; i <= 6; i++) {
78 | var $headings = this.findOrFilter($scope, 'h' + i);
79 | if ($headings.length > 1) {
80 | return i;
81 | }
82 | }
83 |
84 | return 1;
85 | },
86 |
87 | // returns the elements for the top level, and the next below it
88 | getHeadings: function($scope, topLevel) {
89 | var topSelector = 'h' + topLevel;
90 |
91 | var secondaryLevel = topLevel + 1;
92 | var secondarySelector = 'h' + secondaryLevel;
93 |
94 | return this.findOrFilter($scope, topSelector + ',' + secondarySelector);
95 | },
96 |
97 | getNavLevel: function(el) {
98 | return parseInt(el.tagName.charAt(1), 10);
99 | },
100 |
101 | populateNav: function($topContext, topLevel, $headings) {
102 | var $context = $topContext;
103 | var $prevNav;
104 |
105 | var helpers = this;
106 | $headings.each(function(i, el) {
107 | var $newNav = helpers.generateNavItem(el);
108 | var navLevel = helpers.getNavLevel(el);
109 |
110 | // determine the proper $context
111 | if (navLevel === topLevel) {
112 | // use top level
113 | $context = $topContext;
114 | } else if ($prevNav && $context === $topContext) {
115 | // create a new level of the tree and switch to it
116 | $context = helpers.createChildNavList($prevNav);
117 | } // else use the current $context
118 |
119 | $context.append($newNav);
120 |
121 | $prevNav = $newNav;
122 | });
123 | },
124 |
125 | parseOps: function(arg) {
126 | var opts;
127 | if (arg.jquery) {
128 | opts = {
129 | $nav: arg
130 | };
131 | } else {
132 | opts = arg;
133 | }
134 | opts.$scope = opts.$scope || $(document.body);
135 | return opts;
136 | }
137 | },
138 |
139 | // accepts a jQuery object, or an options object
140 | init: function(opts) {
141 | opts = this.helpers.parseOps(opts);
142 |
143 | // ensure that the data attribute is in place for styling
144 | opts.$nav.attr('data-toggle', 'toc');
145 |
146 | var $topContext = this.helpers.createChildNavList(opts.$nav);
147 | var topLevel = this.helpers.getTopLevel(opts.$scope);
148 | var $headings = this.helpers.getHeadings(opts.$scope, topLevel);
149 | this.helpers.populateNav($topContext, topLevel, $headings);
150 | }
151 | };
152 |
153 | $(function() {
154 | $('nav[data-toggle="toc"]').each(function(i, el) {
155 | var $nav = $(el);
156 | Toc.init($nav);
157 | });
158 | });
159 | })();
160 |
--------------------------------------------------------------------------------
/inst/extdata/EX.csv:
--------------------------------------------------------------------------------
1 | STUDYID,DOMAIN,USUBJID,EXSEQ,EXTRT,EXDOSE,EXDOSTXT,EXDOSU,EXDOSFRM,EXSTDTC,EXENDTC
2 | ABC,EX,ABC-01-049,1,ARM D,,0-15,ug/g,CREAM,2006-11-07,2007-02-08
3 | ABC,EX,ABC-01-050,1,ARM B,,0-15,ug/g,CREAM,2006-11-02,2007-01-29
4 | ABC,EX,ABC-01-051,1,ARM A,,0-15,ug/g,CREAM,2006-11-02,2007-01-29
5 | ABC,EX,ABC-01-052,1,ARM C,,0-15,ug/g,CREAM,2006-11-06,2007-01-31
6 | ABC,EX,ABC-01-053,1,ARM B,,0-15,ug/g,CREAM,2006-11-08,2006-12-12
7 | ABC,EX,ABC-01-054,1,ARM D,,0-15,ug/g,CREAM,2006-11-16,2007-02-20
8 | ABC,EX,ABC-01-055,1,ARM C,,0-15,ug/g,CREAM,2006-11-21,2007-02-28
9 | ABC,EX,ABC-01-056,1,ARM A,,0-15,ug/g,CREAM,2006-11-28,2007-02-21
10 | ABC,EX,ABC-01-113,1,ARM D,,0-15,ug/g,CREAM,2006-12-05,2007-03-05
11 | ABC,EX,ABC-01-114,1,ARM B,,0-15,ug/g,CREAM,2006-12-14,2007-03-04
12 | ABC,EX,ABC-02-033,1,ARM C,,0-15,ug/g,CREAM,2006-10-25,2007-01-17
13 | ABC,EX,ABC-02-034,1,ARM A,,0-15,ug/g,CREAM,2006-10-26,2007-01-17
14 | ABC,EX,ABC-02-035,1,ARM B,,0-15,ug/g,CREAM,2006-10-31,2007-01-22
15 | ABC,EX,ABC-02-036,1,ARM D,,0-15,ug/g,CREAM,2006-11-01,2007-01-23
16 | ABC,EX,ABC-02-037,1,ARM C,,0-15,ug/g,CREAM,2006-11-01,2007-01-18
17 | ABC,EX,ABC-02-038,1,ARM A,,0-15,ug/g,CREAM,2006-11-13,2007-02-06
18 | ABC,EX,ABC-02-039,1,ARM B,,0-15,ug/g,CREAM,2006-11-15,2007-02-06
19 | ABC,EX,ABC-02-040,1,ARM D,,0-15,ug/g,CREAM,2006-12-07,2007-02-28
20 | ABC,EX,ABC-02-109,1,ARM A,,0-15,ug/g,CREAM,2006-12-07,2007-02-28
21 | ABC,EX,ABC-02-110,1,ARM B,,0-15,ug/g,CREAM,2006-12-18,2007-03-12
22 | ABC,EX,ABC-02-111,1,ARM D,,0-15,ug/g,CREAM,2006-12-19,2007-03-15
23 | ABC,EX,ABC-02-112,1,ARM C,,0-15,ug/g,CREAM,2006-12-19,2007-03-14
24 | ABC,EX,ABC-03-001,1,ARM B,,0-15,ug/g,CREAM,2006-10-10,2007-01-01
25 | ABC,EX,ABC-03-002,1,ARM A,,0-15,ug/g,CREAM,2006-10-11,2007-01-01
26 | ABC,EX,ABC-03-003,1,ARM D,,0-15,ug/g,CREAM,2006-10-11,2007-01-02
27 | ABC,EX,ABC-03-004,1,ARM C,,0-15,ug/g,CREAM,2006-10-12,2007-01-03
28 | ABC,EX,ABC-03-006,1,ARM A,,0-15,ug/g,CREAM,2006-10-25,2007-01-16
29 | ABC,EX,ABC-03-007,1,ARM B,,0-15,ug/g,CREAM,2006-10-31,2007-01-21
30 | ABC,EX,ABC-03-008,1,ARM D,,0-15,ug/g,CREAM,2006-11-02,2006-11-09
31 | ABC,EX,ABC-03-089,1,ARM D,,0-15,ug/g,CREAM,2006-11-21,2007-02-12
32 | ABC,EX,ABC-03-090,1,,,0-15,ug/g,CREAM,2006-12-06,2007-02-27
33 | ABC,EX,ABC-03-091,1,ARM A,,0-15,ug/g,CREAM,2006-12-20,2007-03-13
34 | ABC,EX,ABC-04-073,1,ARM D,,0-15,ug/g,CREAM,2006-10-31,2007-01-24
35 | ABC,EX,ABC-04-074,1,ARM C,,0-15,ug/g,CREAM,2006-11-01,2006-11-08
36 | ABC,EX,ABC-04-075,1,ARM A,,0-15,ug/g,CREAM,2006-11-09,2007-02-08
37 | ABC,EX,ABC-04-076,1,ARM B,,0-15,ug/g,CREAM,2006-11-15,2007-02-07
38 | ABC,EX,ABC-04-077,1,ARM C,,0-15,ug/g,CREAM,2006-11-15,2007-02-11
39 | ABC,EX,ABC-04-078,1,ARM D,,0-15,ug/g,CREAM,2006-12-13,2007-03-07
40 | ABC,EX,ABC-04-079,1,ARM B,,0-15,ug/g,CREAM,2006-12-18,2007-03-13
41 | ABC,EX,ABC-04-080,1,ARM A,,0-15,ug/g,CREAM,2006-12-21,2007-03-13
42 | ABC,EX,ABC-04-125,1,ARM D,,0-15,ug/g,CREAM,2006-12-29,2007-03-23
43 | ABC,EX,ABC-04-126,1,ARM A,,0-15,ug/g,CREAM,2007-01-02,2007-03-27
44 | ABC,EX,ABC-04-127,1,ARM B,,0-15,ug/g,CREAM,2007-01-03,2007-04-06
45 | ABC,EX,ABC-04-129,1,ARM D,,0-15,ug/g,CREAM,2007-01-05,2007-03-28
46 | ABC,EX,ABC-04-130,1,ARM C,,0-15,ug/g,CREAM,2007-01-08,2007-04-02
47 | ABC,EX,ABC-04-131,1,ARM B,,0-15,ug/g,CREAM,2007-01-10,2007-04-04
48 | ABC,EX,ABC-06-065,1,ARM C,,0-15,ug/g,CREAM,2006-11-08,2007-01-31
49 | ABC,EX,ABC-06-066,1,ARM B,,0-15,ug/g,CREAM,2006-11-14,2007-02-08
50 | ABC,EX,ABC-06-067,1,ARM D,,0-15,ug/g,CREAM,2006-11-21,2007-02-12
51 | ABC,EX,ABC-06-068,1,ARM A,,0-15,ug/g,CREAM,2006-11-22,2007-02-15
52 | ABC,EX,ABC-06-069,1,ARM A,,0-15,ug/g,CREAM,2006-11-27,2007-01-04
53 | ABC,EX,ABC-06-070,1,ARM B,,0-15,ug/g,CREAM,2006-11-29,2007-02-20
54 | ABC,EX,ABC-06-071,1,ARM D,,0-15,ug/g,CREAM,2006-11-29,2007-02-21
55 | ABC,EX,ABC-06-072,1,ARM C,,0-15,ug/g,CREAM,2006-12-05,2007-02-27
56 | ABC,EX,ABC-06-161,1,ARM C,,0-15,ug/g,CREAM,2006-12-12,2007-01-03
57 | ABC,EX,ABC-06-162,1,,,0-15,ug/g,CREAM,2006-12-28,2007-03-21
58 | ABC,EX,ABC-06-163,1,ARM D,,0-15,ug/g,CREAM,2007-01-08,2007-04-01
59 | ABC,EX,ABC-07-009,1,ARM C,,0-15,ug/g,CREAM,2006-10-18,2007-01-10
60 | ABC,EX,ABC-07-010,1,ARM B,,0-15,ug/g,CREAM,2006-11-22,2007-02-07
61 | ABC,EX,ABC-07-011,1,ARM D,,0-15,ug/g,CREAM,2006-11-22,2007-02-07
62 | ABC,EX,ABC-07-012,1,ARM A,,0-15,ug/g,CREAM,2006-12-13,2007-03-07
63 | ABC,EX,ABC-07-013,1,ARM D,,0-15,ug/g,CREAM,2006-12-18,2007-03-12
64 | ABC,EX,ABC-07-014,1,ARM C,,0-15,ug/g,CREAM,2006-12-18,2007-03-12
65 | ABC,EX,ABC-07-015,1,ARM B,,0-15,ug/g,CREAM,2006-12-20,2007-03-20
66 | ABC,EX,ABC-07-016,1,ARM A,,0-15,ug/g,CREAM,2006-12-26,2007-03-18
67 | ABC,EX,ABC-08-101,1,ARM C,,0-15,ug/g,CREAM,2006-11-07,2007-01-30
68 | ABC,EX,ABC-08-102,1,ARM D,,0-15,ug/g,CREAM,2006-11-09,2007-01-30
69 | ABC,EX,ABC-08-103,1,ARM B,,0-15,ug/g,CREAM,2006-11-09,2007-01-30
70 | ABC,EX,ABC-08-104,1,ARM A,,0-15,ug/g,CREAM,2006-11-09,2007-02-08
71 | ABC,EX,ABC-08-105,1,ARM C,,0-15,ug/g,CREAM,2006-11-13,2007
72 | ABC,EX,ABC-08-106,1,ARM A,,0-15,ug/g,CREAM,2006-11-14,2007-02-04
73 | ABC,EX,ABC-08-107,1,ARM D,,0-15,ug/g,CREAM,2006-11-21,2007-01-03
74 | ABC,EX,ABC-08-108,1,ARM B,,0-15,ug/g,CREAM,2006-12-22,2007
75 | ABC,EX,ABC-09-017,1,ARM C,,0-15,ug/g,CREAM,2006-10-18,2007-01-10
76 | ABC,EX,ABC-09-018,1,ARM B,,0-15,ug/g,CREAM,2006-10-18,2007-01-09
77 | ABC,EX,ABC-09-019,1,ARM D,,0-15,ug/g,CREAM,2006-10-18,2007-01-10
78 | ABC,EX,ABC-09-020,1,ARM A,,0-15,ug/g,CREAM,2006-10-18,2007-01-09
79 | ABC,EX,ABC-09-021,1,ARM B,,0-15,ug/g,CREAM,2006-11-01,2006-11-01
80 | ABC,EX,ABC-09-023,1,ARM A,,0-15,ug/g,CREAM,2006-11-16,2007-02-09
81 | ABC,EX,ABC-09-024,1,ARM C,,0-15,ug/g,CREAM,2006-11-16,2007-02-08
82 | ABC,EX,ABC-09-137,1,ARM A,,0-15,ug/g,CREAM,2006-11-21,2007-02-14
83 | ABC,EX,ABC-09-138,1,ARM D,,0-15,ug/g,CREAM,2006-11-21,2007-02-14
84 | ABC,EX,ABC-09-139,1,ARM C,,0-15,ug/g,CREAM,2006-11-21,2007-02-15
85 | ABC,EX,ABC-09-140,1,ARM B,,0-15,ug/g,CREAM,2006-11-28,2007-02-19
86 |
--------------------------------------------------------------------------------
/tests/testthat/data/SDTM/EX.csv:
--------------------------------------------------------------------------------
1 | STUDYID,DOMAIN,USUBJID,EXSEQ,EXTRT,EXDOSE,EXDOSTXT,EXDOSU,EXDOSFRM,EXSTDTC,EXENDTC
2 | ABC,EX,ABC-01-049,1,ARM D,,0-15,ug/g,CREAM,2006-11-07,2007-02-08
3 | ABC,EX,ABC-01-050,1,ARM B,,0-15,ug/g,CREAM,2006-11-02,2007-01-29
4 | ABC,EX,ABC-01-051,1,ARM A,,0-15,ug/g,CREAM,2006-11-02,2007-01-29
5 | ABC,EX,ABC-01-052,1,ARM C,,0-15,ug/g,CREAM,2006-11-06,2007-01-31
6 | ABC,EX,ABC-01-053,1,ARM B,,0-15,ug/g,CREAM,2006-11-08,2006-12-12
7 | ABC,EX,ABC-01-054,1,ARM D,,0-15,ug/g,CREAM,2006-11-16,2007-02-20
8 | ABC,EX,ABC-01-055,1,ARM C,,0-15,ug/g,CREAM,2006-11-21,2007-02-28
9 | ABC,EX,ABC-01-056,1,ARM A,,0-15,ug/g,CREAM,2006-11-28,2007-02-21
10 | ABC,EX,ABC-01-113,1,ARM D,,0-15,ug/g,CREAM,2006-12-05,2007-03-05
11 | ABC,EX,ABC-01-114,1,ARM B,,0-15,ug/g,CREAM,2006-12-14,2007-03-04
12 | ABC,EX,ABC-02-033,1,ARM C,,0-15,ug/g,CREAM,2006-10-25,2007-01-17
13 | ABC,EX,ABC-02-034,1,ARM A,,0-15,ug/g,CREAM,2006-10-26,2007-01-17
14 | ABC,EX,ABC-02-035,1,ARM B,,0-15,ug/g,CREAM,2006-10-31,2007-01-22
15 | ABC,EX,ABC-02-036,1,ARM D,,0-15,ug/g,CREAM,2006-11-01,2007-01-23
16 | ABC,EX,ABC-02-037,1,ARM C,,0-15,ug/g,CREAM,2006-11-01,2007-01-18
17 | ABC,EX,ABC-02-038,1,ARM A,,0-15,ug/g,CREAM,2006-11-13,2007-02-06
18 | ABC,EX,ABC-02-039,1,ARM B,,0-15,ug/g,CREAM,2006-11-15,2007-02-06
19 | ABC,EX,ABC-02-040,1,ARM D,,0-15,ug/g,CREAM,2006-12-07,2007-02-28
20 | ABC,EX,ABC-02-109,1,ARM A,,0-15,ug/g,CREAM,2006-12-07,2007-02-28
21 | ABC,EX,ABC-02-110,1,ARM B,,0-15,ug/g,CREAM,2006-12-18,2007-03-12
22 | ABC,EX,ABC-02-111,1,ARM D,,0-15,ug/g,CREAM,2006-12-19,2007-03-15
23 | ABC,EX,ABC-02-112,1,ARM C,,0-15,ug/g,CREAM,2006-12-19,2007-03-14
24 | ABC,EX,ABC-03-001,1,ARM B,,0-15,ug/g,CREAM,2006-10-10,2007-01-01
25 | ABC,EX,ABC-03-002,1,ARM A,,0-15,ug/g,CREAM,2006-10-11,2007-01-01
26 | ABC,EX,ABC-03-003,1,ARM D,,0-15,ug/g,CREAM,2006-10-11,2007-01-02
27 | ABC,EX,ABC-03-004,1,ARM C,,0-15,ug/g,CREAM,2006-10-12,2007-01-03
28 | ABC,EX,ABC-03-006,1,ARM A,,0-15,ug/g,CREAM,2006-10-25,2007-01-16
29 | ABC,EX,ABC-03-007,1,ARM B,,0-15,ug/g,CREAM,2006-10-31,2007-01-21
30 | ABC,EX,ABC-03-008,1,ARM D,,0-15,ug/g,CREAM,2006-11-02,2006-11-09
31 | ABC,EX,ABC-03-089,1,ARM D,,0-15,ug/g,CREAM,2006-11-21,2007-02-12
32 | ABC,EX,ABC-03-090,1,,,0-15,ug/g,CREAM,2006-12-06,2007-02-27
33 | ABC,EX,ABC-03-091,1,ARM A,,0-15,ug/g,CREAM,2006-12-20,2007-03-13
34 | ABC,EX,ABC-04-073,1,ARM D,,0-15,ug/g,CREAM,2006-10-31,2007-01-24
35 | ABC,EX,ABC-04-074,1,ARM C,,0-15,ug/g,CREAM,2006-11-01,2006-11-08
36 | ABC,EX,ABC-04-075,1,ARM A,,0-15,ug/g,CREAM,2006-11-09,2007-02-08
37 | ABC,EX,ABC-04-076,1,ARM B,,0-15,ug/g,CREAM,2006-11-15,2007-02-07
38 | ABC,EX,ABC-04-077,1,ARM C,,0-15,ug/g,CREAM,2006-11-15,2007-02-11
39 | ABC,EX,ABC-04-078,1,ARM D,,0-15,ug/g,CREAM,2006-12-13,2007-03-07
40 | ABC,EX,ABC-04-079,1,ARM B,,0-15,ug/g,CREAM,2006-12-18,2007-03-13
41 | ABC,EX,ABC-04-080,1,ARM A,,0-15,ug/g,CREAM,2006-12-21,2007-03-13
42 | ABC,EX,ABC-04-125,1,ARM D,,0-15,ug/g,CREAM,2006-12-29,2007-03-23
43 | ABC,EX,ABC-04-126,1,ARM A,,0-15,ug/g,CREAM,2007-01-02,2007-03-27
44 | ABC,EX,ABC-04-127,1,ARM B,,0-15,ug/g,CREAM,2007-01-03,2007-04-06
45 | ABC,EX,ABC-04-129,1,ARM D,,0-15,ug/g,CREAM,2007-01-05,2007-03-28
46 | ABC,EX,ABC-04-130,1,ARM C,,0-15,ug/g,CREAM,2007-01-08,2007-04-02
47 | ABC,EX,ABC-04-131,1,ARM B,,0-15,ug/g,CREAM,2007-01-10,2007-04-04
48 | ABC,EX,ABC-06-065,1,ARM C,,0-15,ug/g,CREAM,2006-11-08,2007-01-31
49 | ABC,EX,ABC-06-066,1,ARM B,,0-15,ug/g,CREAM,2006-11-14,2007-02-08
50 | ABC,EX,ABC-06-067,1,ARM D,,0-15,ug/g,CREAM,2006-11-21,2007-02-12
51 | ABC,EX,ABC-06-068,1,ARM A,,0-15,ug/g,CREAM,2006-11-22,2007-02-15
52 | ABC,EX,ABC-06-069,1,ARM A,,0-15,ug/g,CREAM,2006-11-27,2007-01-04
53 | ABC,EX,ABC-06-070,1,ARM B,,0-15,ug/g,CREAM,2006-11-29,2007-02-20
54 | ABC,EX,ABC-06-071,1,ARM D,,0-15,ug/g,CREAM,2006-11-29,2007-02-21
55 | ABC,EX,ABC-06-072,1,ARM C,,0-15,ug/g,CREAM,2006-12-05,2007-02-27
56 | ABC,EX,ABC-06-161,1,ARM C,,0-15,ug/g,CREAM,2006-12-12,2007-01-03
57 | ABC,EX,ABC-06-162,1,,,0-15,ug/g,CREAM,2006-12-28,2007-03-21
58 | ABC,EX,ABC-06-163,1,ARM D,,0-15,ug/g,CREAM,2007-01-08,2007-04-01
59 | ABC,EX,ABC-07-009,1,ARM C,,0-15,ug/g,CREAM,2006-10-18,2007-01-10
60 | ABC,EX,ABC-07-010,1,ARM B,,0-15,ug/g,CREAM,2006-11-22,2007-02-07
61 | ABC,EX,ABC-07-011,1,ARM D,,0-15,ug/g,CREAM,2006-11-22,2007-02-07
62 | ABC,EX,ABC-07-012,1,ARM A,,0-15,ug/g,CREAM,2006-12-13,2007-03-07
63 | ABC,EX,ABC-07-013,1,ARM D,,0-15,ug/g,CREAM,2006-12-18,2007-03-12
64 | ABC,EX,ABC-07-014,1,ARM C,,0-15,ug/g,CREAM,2006-12-18,2007-03-12
65 | ABC,EX,ABC-07-015,1,ARM B,,0-15,ug/g,CREAM,2006-12-20,2007-03-20
66 | ABC,EX,ABC-07-016,1,ARM A,,0-15,ug/g,CREAM,2006-12-26,2007-03-18
67 | ABC,EX,ABC-08-101,1,ARM C,,0-15,ug/g,CREAM,2006-11-07,2007-01-30
68 | ABC,EX,ABC-08-102,1,ARM D,,0-15,ug/g,CREAM,2006-11-09,2007-01-30
69 | ABC,EX,ABC-08-103,1,ARM B,,0-15,ug/g,CREAM,2006-11-09,2007-01-30
70 | ABC,EX,ABC-08-104,1,ARM A,,0-15,ug/g,CREAM,2006-11-09,2007-02-08
71 | ABC,EX,ABC-08-105,1,ARM C,,0-15,ug/g,CREAM,2006-11-13,2007
72 | ABC,EX,ABC-08-106,1,ARM A,,0-15,ug/g,CREAM,2006-11-14,2007-02-04
73 | ABC,EX,ABC-08-107,1,ARM D,,0-15,ug/g,CREAM,2006-11-21,2007-01-03
74 | ABC,EX,ABC-08-108,1,ARM B,,0-15,ug/g,CREAM,2006-12-22,2007
75 | ABC,EX,ABC-09-017,1,ARM C,,0-15,ug/g,CREAM,2006-10-18,2007-01-10
76 | ABC,EX,ABC-09-018,1,ARM B,,0-15,ug/g,CREAM,2006-10-18,2007-01-09
77 | ABC,EX,ABC-09-019,1,ARM D,,0-15,ug/g,CREAM,2006-10-18,2007-01-10
78 | ABC,EX,ABC-09-020,1,ARM A,,0-15,ug/g,CREAM,2006-10-18,2007-01-09
79 | ABC,EX,ABC-09-021,1,ARM B,,0-15,ug/g,CREAM,2006-11-01,2006-11-01
80 | ABC,EX,ABC-09-023,1,ARM A,,0-15,ug/g,CREAM,2006-11-16,2007-02-09
81 | ABC,EX,ABC-09-024,1,ARM C,,0-15,ug/g,CREAM,2006-11-16,2007-02-08
82 | ABC,EX,ABC-09-137,1,ARM A,,0-15,ug/g,CREAM,2006-11-21,2007-02-14
83 | ABC,EX,ABC-09-138,1,ARM D,,0-15,ug/g,CREAM,2006-11-21,2007-02-14
84 | ABC,EX,ABC-09-139,1,ARM C,,0-15,ug/g,CREAM,2006-11-21,2007-02-15
85 | ABC,EX,ABC-09-140,1,ARM B,,0-15,ug/g,CREAM,2006-11-28,2007-02-19
86 |
--------------------------------------------------------------------------------
/vignettes/libr-basics.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Basic Library Operations"
3 | output: rmarkdown::html_vignette
4 | vignette: >
5 | %\VignetteIndexEntry{Basic Library Operations}
6 | %\VignetteEngine{knitr::rmarkdown}
7 | %\VignetteEncoding{UTF-8}
8 | ---
9 |
10 | ```{r setup, include = FALSE}
11 | knitr::opts_chunk$set(
12 | collapse = TRUE,
13 | comment = "#>"
14 | )
15 | ```
16 | The main motivation for developing the **libr** package is to create and use
17 | data libraries and data dictionaries. These concepts are useful when
18 | dealing with sets of related data files. The `libname()` function allows
19 | you to define a library for an entire directory of data files. The library
20 | can then be manipulated as a whole using the `lib_*` functions in the **libr**
21 | package.
22 |
23 |
24 | ### Basic Library Operations
25 | There are four main **libr** functions for creating and using a data library:
26 |
27 | * `libname()`
28 | * `lib_load()`
29 | * `lib_unload()`
30 | * `lib_write()`
31 |
32 | The `libname()` function creates a data library. The function has parameters
33 | for the library name and a directory to associate it with. If the directory
34 | has existing data files, those data files will be automatically loaded
35 | into the library. Once in the library, the data can be accessed using list
36 | syntax.
37 |
38 | You may create a data library for several different types of files: 'rds', 'Rdata',
39 | 'rda', 'csv', 'xlsx', 'xls', 'sas7bdat', 'xpt', and 'dbf'. The type of library is
40 | defined using the `engine` parameter on the `libname()` function. The default
41 | data engine is 'rds'. The data engines will attempt to identify the correct
42 | data type for each column of data. You may also control the data type of
43 | the columns using the `import_specs` parameter and the `specs()` and
44 | `import_spec()` functions.
45 |
46 | If you prefer to access the data via the workspace, call
47 | the `lib_load()` function on the library. This function will load the
48 | library data into the parent frame, where it can be accessed using a two-level
49 | (<library>.<dataset>) name.
50 |
51 | When you are done with the data, call the `lib_unload()` function to remove
52 | the data from the parent frame and put it back in the library list. To write
53 | any added or modified data to disk, call the `lib_write()` function. The
54 | `lib_write()` function will only write data that has changed since the last
55 | write.
56 |
57 | The following example will illustrate some basic functionality of the
58 | **libr** package regarding the creation of libnames and use of dictionaries.
59 | The example first places some sample data in a temp directory for
60 | illustration purposes. Then the example creates a libname from the temp
61 | directory, loads it into memory, adds data to it, and then unloads and
62 | writes everything to disk:
63 | ```{r eval=FALSE, echo=TRUE}
64 | library(libr)
65 |
66 | # Create temp directory
67 | tmp <- tempdir()
68 |
69 | # Save some data to temp directory
70 | # for illustration purposes
71 | saveRDS(trees, file.path(tmp, "trees.rds"))
72 | saveRDS(rock, file.path(tmp, "rocks.rds"))
73 |
74 | # Create library
75 | libname(dat, tmp)
76 | # library 'dat': 2 items
77 | # - attributes: not loaded
78 | # - path: C:\Users\User\AppData\Local\Temp\RtmpCSJ6Gc
79 | # - items:
80 | # Name Extension Rows Cols Size LastModified
81 | # 1 rocks rds 48 4 3.1 Kb 2020-11-05 23:25:34
82 | # 2 trees rds 31 3 2.4 Kb 2020-11-05 23:25:34
83 |
84 | # Examine data dictionary for library
85 | dictionary(dat)
86 | # A tibble: 7 x 9
87 | # Name Column Class Label Description Format Width Rows NAs
88 | #
89 | # 1 rocks area integer NA NA NA NA 48 0
90 | # 2 rocks peri numeric NA NA NA NA 48 0
91 | # 3 rocks shape numeric NA NA NA NA 48 0
92 | # 4 rocks perm numeric NA NA NA NA 48 0
93 | # 5 trees Girth numeric NA NA NA NA 31 0
94 | # 6 trees Height numeric NA NA NA NA 31 0
95 | # 7 trees Volume numeric NA NA NA NA 31 0
96 |
97 | # Load library
98 | lib_load(dat)
99 |
100 | # Examine workspace
101 | ls()
102 | # [1] "dat" "dat.rocks" "dat.trees" "tmp"
103 |
104 | # Use data from the library
105 | summary(dat.rocks)
106 | # area peri shape perm
107 | # Min. : 1016 Min. : 308.6 Min. :0.09033 Min. : 6.30
108 | # 1st Qu.: 5305 1st Qu.:1414.9 1st Qu.:0.16226 1st Qu.: 76.45
109 | # Median : 7487 Median :2536.2 Median :0.19886 Median : 130.50
110 | # Mean : 7188 Mean :2682.2 Mean :0.21811 Mean : 415.45
111 | # 3rd Qu.: 8870 3rd Qu.:3989.5 3rd Qu.:0.26267 3rd Qu.: 777.50
112 | # Max. :12212 Max. :4864.2 Max. :0.46413 Max. :1300.00
113 |
114 | # Add data to the library
115 | dat.trees_subset <- subset(dat.trees, Girth > 11)
116 |
117 | # Add more data to the library
118 | dat.cars <- mtcars
119 |
120 | # Unload the library from memory
121 | lib_unload(dat)
122 |
123 | # Examine workspace again
124 | ls()
125 | # [1] "dat" "tmp"
126 |
127 | # Write the library to disk
128 | lib_write(dat)
129 | # library 'dat': 4 items
130 | # - attributes: not loaded
131 | # - path: C:\Users\User\AppData\Local\Temp\RtmpCSJ6Gc
132 | # - items:
133 | # Name Extension Rows Cols Size LastModified
134 | # 1 rocks rds 48 4 3.1 Kb 2020-11-05 23:37:45
135 | # 2 trees rds 31 3 2.4 Kb 2020-11-05 23:37:45
136 | # 3 cars rds 32 11 7.3 Kb 2020-11-05 23:37:45
137 | # 4 trees_subset rds 23 3 1.8 Kb 2020-11-05 23:37:45
138 |
139 | # Clean up
140 | lib_delete(dat)
141 |
142 | # Examine workspace again
143 | ls()
144 | # [1] "tmp"
145 | ```
146 |
147 |
148 | Next: [Library Management](libr-management.html)
149 |
--------------------------------------------------------------------------------
/man/specs.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/specs.R
3 | \encoding{UTF-8}
4 | \name{specs}
5 | \alias{specs}
6 | \title{Create an Import Spec Collection}
7 | \usage{
8 | specs(..., na = c("", "NA"), trim_ws = TRUE)
9 | }
10 | \arguments{
11 | \item{...}{Named input specs. The name should correspond to the file name,
12 | without the file extension.
13 | The spec is defined as an \code{import_spec} object. See the
14 | \code{\link{import_spec}} function for additional information on
15 | parameters for that object.}
16 |
17 | \item{na}{A vector of values to be treated as NA. For example, the
18 | vector \code{c('', ' ')} will cause empty strings and single blanks to
19 | be converted to NA values. For most file types,
20 | empty strings and the string 'NA' \code{('', 'NA')} are considered NA.
21 | For SAS® datasets and transport files, a single blank and a single dot
22 | \code{c(" ", ".")} are considered NA. The value of the
23 | \code{na} parameter on the \code{specs} function can be overridden
24 | by the \code{na} parameter on the \code{import_spec} function.}
25 |
26 | \item{trim_ws}{Whether or not to trim white space from the input data values.
27 | Valid values are TRUE, and FALSE. Default is TRUE. The value of the
28 | \code{trim_ws} parameter on the \code{specs} function can be overridden
29 | by the \code{trim_ws} parameter on the \code{import_spec} function.}
30 | }
31 | \value{
32 | The import specifications object.
33 | }
34 | \description{
35 | A function to capture a set of import specifications for a
36 | directory of data files. These specs can be used on the
37 | \code{\link{libname}} function to correctly assign the data types for
38 | imported data files. The
39 | import engines will guess at the data types for any columns that
40 | are not explicitly defined in the import specifications. Import
41 | specifications are defined with the \code{\link{import_spec}} function.
42 | The import spec syntax is the same for all data engines.
43 |
44 | Note that the \code{na} and \code{trim_ws} parameters on the \code{specs}
45 | function will be applied globally to all files in the library.
46 | These global settings can be overridden on the \code{\link{import_spec}}
47 | for any particular data file.
48 |
49 | Also note that the \code{specs} collection is defined as an object
50 | so it can be stored and reused.
51 | See the \code{\link{write.specs}} and \code{\link{read.specs}} functions
52 | for additional information on saving specs.
53 | }
54 | \examples{
55 | library(readr)
56 |
57 | # Create temp path
58 | tmp <- file.path(tempdir(), "mtcars.csv")
59 |
60 | # Create data for illustration purposes
61 | df <- data.frame(vehicle = rownames(mtcars), mtcars[c("mpg", "cyl", "disp")],
62 | stringsAsFactors = FALSE)
63 |
64 | # Kill rownames
65 | rownames(df) <- NULL
66 |
67 | # Add some columns
68 | df <- datastep(df[1:10, ], {
69 |
70 | recdt <- "10JUN1974"
71 |
72 | if (mpg >= 20)
73 | mpgcat <- "High"
74 | else
75 | mpgcat <- "Low"
76 |
77 | if (cyl == 8)
78 | cyl8 <- TRUE
79 | })
80 |
81 | df
82 | # vehicle mpg cyl disp recdt mpgcat cyl8
83 | # 1 Mazda RX4 21.0 6 160.0 10JUN1974 High NA
84 | # 2 Mazda RX4 Wag 21.0 6 160.0 10JUN1974 High NA
85 | # 3 Datsun 710 22.8 4 108.0 10JUN1974 High NA
86 | # 4 Hornet 4 Drive 21.4 6 258.0 10JUN1974 High NA
87 | # 5 Hornet Sportabout 18.7 8 360.0 10JUN1974 Low TRUE
88 | # 6 Valiant 18.1 6 225.0 10JUN1974 Low NA
89 | # 7 Duster 360 14.3 8 360.0 10JUN1974 Low TRUE
90 | # 8 Merc 240D 24.4 4 146.7 10JUN1974 High NA
91 | # 9 Merc 230 22.8 4 140.8 10JUN1974 High NA
92 | # 10 Merc 280 19.2 6 167.6 10JUN1974 Low NA
93 |
94 | # Save to temp directory for this example
95 | write_csv(df, tmp)
96 |
97 | ## Start Example ##
98 |
99 | # Define import spec
100 | spcs <- specs(mtcars = import_spec(vehicle = "character",
101 | cyl = "integer",
102 | recdt = "date=\%d\%b\%Y",
103 | mpgcat = "guess",
104 | cyl8 = "logical"))
105 |
106 | # Create library
107 | libname(dat, tempdir(), "csv", import_specs = spcs)
108 | # $mtcars
109 | # library 'dat': 1 items
110 | # - attributes: csv not loaded
111 | # - path: C:\Users\User\AppData\Local\Temp\RtmpqAMV6L
112 | # - items:
113 | # Name Extension Rows Cols Size LastModified
114 | # 1 mtcars csv 10 7 9.3 Kb 2020-11-29 09:47:52
115 |
116 | # View data types
117 | dictionary(dat)
118 | # # A tibble: 7 x 10
119 | # Name Column Class Label Description Format Width Justify Rows NAs
120 | #
121 | # 1 mtcars vehicle character NA NA NA 17 NA 10 0
122 | # 2 mtcars mpg numeric NA NA NA NA NA 10 0
123 | # 3 mtcars cyl integer NA NA NA NA NA 10 0
124 | # 4 mtcars disp numeric NA NA NA NA NA 10 0
125 | # 5 mtcars mpgcat character NA NA NA 4 NA 10 0
126 | # 6 mtcars recdt Date NA NA NA NA NA 10 0
127 | # 7 mtcars cyl8 logical NA NA NA NA NA 10 8
128 |
129 | # Clean up
130 | lib_delete(dat)
131 | }
132 | \seealso{
133 | \code{\link{libname}} to create a data library,
134 | \code{\link{dictionary}} for generating a data dictionary, and
135 | \code{\link{import_spec}} for additional information on defining an
136 | import spec.
137 |
138 | Other specs:
139 | \code{\link{import_spec}()},
140 | \code{\link{print.specs}()},
141 | \code{\link{read.specs}()},
142 | \code{\link{write.specs}()}
143 | }
144 | \concept{specs}
145 |
--------------------------------------------------------------------------------
/R/dictionary.R:
--------------------------------------------------------------------------------
1 |
2 |
3 | # Dictionary Definition ---------------------------------------------------
4 |
5 |
6 |
7 | #' @title Create a Data Dictionary
8 | #' @param x The input library, data frame, or tibble.
9 | #' @description A function to create a data dictionary for a data frame,
10 | #' a tibble, or a data library. The function will generate a tibble of
11 | #' information about the data. The tibble will contain the following columns:
12 | #' \itemize{
13 | #' \item{\strong{Name:} The name of the data object.}
14 | #' \item{\strong{Column:} The name of the column.}
15 | #' \item{\strong{Class:} The class of the column.}
16 | #' \item{\strong{Label:} The value of the label attribute.}
17 | #' \item{\strong{Description:} A description applied to this column.}
18 | #' \item{\strong{Format:} The value of the format attribute.}
19 | #' \item{\strong{Width:} The value of the width attribute if any have been
20 | #' assigned.}
21 | #' \item{\strong{Justify:} The justification or alignment attribute value.}
22 | #' \item{\strong{Rows:} The number of data rows.}
23 | #' \item{\strong{NAs:} The number of NA values in this column.}
24 | #' \item{\strong{MaxChar:} The maximum character length of the
25 | #' values in this column with no padding.}
26 | #' }
27 | #' @import tibble
28 | #' @seealso \code{\link{libname}} to create a data library. Also
29 | #' see the \code{\link{dsattr}} function to set attributes for your
30 | #' dataset from within a \code{\link{datastep}}. To render attributes,
31 | #' see the \strong{fmtr} package.
32 | #' @examples
33 | #' # Create temp directory
34 | #' tmp <- tempdir()
35 | #'
36 | #' # Create library
37 | #' libname(dat, tmp)
38 | #'
39 | #' # Add data to the library
40 | #' lib_add(dat, beaver1)
41 | #' lib_add(dat, iris)
42 | #'
43 | #' # Examine the dictionary for the library
44 | #' dictionary(dat)
45 | #' # A tibble: 9 x 10
46 | #' # Name Column Class Label Description Format Width Justify Rows NAs MaxChar
47 | #' #
48 | #' # 1 beaver1 day numeric NA NA NA NA NA 114 0 3
49 | #' # 2 beaver1 time numeric NA NA NA NA NA 114 0 4
50 | #' # 3 beaver1 temp numeric NA NA NA NA NA 114 0 5
51 | #' # 4 beaver1 activ numeric NA NA NA NA NA 114 0 1
52 | #' # 5 iris Sepal.Length numeric NA NA NA NA NA 150 0 3
53 | #' # 6 iris Sepal.Width numeric NA NA NA NA NA 150 0 3
54 | #' # 7 iris Petal.Length numeric NA NA NA NA NA 150 0 3
55 | #' # 8 iris Petal.Width numeric NA NA NA NA NA 150 0 3
56 | #' # 9 iris Species factor NA NA NA NA NA 150 0 10
57 | #'
58 | #' # Clean up
59 | #' lib_delete(dat)
60 | #' @export
61 | dictionary <- function(x) {
62 |
63 |
64 |
65 | if (all(class(x) == "character")) {
66 | lbnm <- x
67 | x <- get(lbnm, envir = e$env)
68 |
69 | } else {
70 |
71 | # Get safe variable name
72 | lbnm <- paste(deparse(substitute(x, env = environment())), collapse = "")
73 | }
74 |
75 | if (!any(class(x) == "lib") & !any(class(x) == "data.frame"))
76 | stop("Input object must be a library or data frame.")
77 |
78 | ret <- NULL
79 | if (any(class(x) == "lib")) {
80 |
81 |
82 | for (nm in names(x)) {
83 |
84 |
85 | if (is.null(ret))
86 | ret <- getDictionary(x[[nm]], nm)
87 | else
88 | ret <- rbind(ret, getDictionary(x[[nm]], nm))
89 |
90 |
91 | }
92 |
93 | } else {
94 |
95 | ret <- getDictionary(x, lbnm)
96 |
97 | }
98 |
99 | ret <- as_tibble(ret)
100 |
101 | return(ret)
102 | }
103 |
104 |
105 | # Utilities ---------------------------------------------------------------
106 |
107 |
108 | #' @noRd
109 | getDictionary <- function(x, dsnm) {
110 |
111 | ret <- NULL
112 | rw <- NULL
113 | usr_wdth <- c()
114 | str_wdth <- c()
115 | cntr <- 0
116 |
117 | for (nm in names(x)) {
118 |
119 | cntr <- cntr + 1
120 |
121 | lbl <- attr(x[[nm]], "label")
122 | desc <- attr(x[[nm]], "description")
123 | fmt <- paste(as.character(attr(x[[nm]], "format")), collapse = "\n")
124 | jst <- attr(x[[nm]], "justify")
125 | wdth <- attr(x[[nm]], "width")
126 |
127 | if (fmt == "")
128 | fmt <- NA
129 |
130 | if (length(x[[nm]]) > 0) {
131 | if (typeof(x[[nm]]) == "character")
132 | str_wdth[cntr] <- suppressWarnings(max(nchar(x[[nm]]), na.rm = TRUE))
133 | else
134 | str_wdth[cntr] <- suppressWarnings(max(nchar(as.character(x[[nm]])),
135 | na.rm = TRUE))
136 |
137 | if (is.na(str_wdth[cntr]) | str_wdth[cntr] == -Inf)
138 | str_wdth[cntr] <- 0
139 |
140 | } else {
141 | str_wdth[cntr] <- NA
142 | }
143 |
144 | rw <- data.frame(Name = dsnm,
145 | Column = nm,
146 | Class = paste0(class(x[[nm]]), collapse = " "),
147 | Label = ifelse(!is.null(lbl), lbl, as.character(NA)),
148 | Description = ifelse(!is.null(desc), desc, as.character(NA)),
149 | Format = ifelse(!is.null(fmt), fmt, NA),
150 | Width = ifelse(!is.null(wdth), wdth, NA),
151 | Justify = ifelse(!is.null(jst), jst, as.character(NA)),
152 | Rows = nrow(x),
153 | NAs = sum(is.na(x[[nm]])),
154 | MaxChar = str_wdth[cntr])
155 |
156 | if (is.null(ret))
157 | ret <- rw
158 | else
159 | ret <- rbind(ret, rw)
160 |
161 | }
162 |
163 |
164 | return(ret)
165 |
166 | }
167 |
168 |
169 |
170 |
--------------------------------------------------------------------------------
/tests/testthat/test-dsattr.R:
--------------------------------------------------------------------------------
1 | context("Datastep Attributes Tests")
2 |
3 | base_path <- "c:\\packages\\libr\\tests\\testthat\\data"
4 |
5 | base_path <- "./data"
6 |
7 | DEV <- FALSE
8 |
9 |
10 | test_that("dsattr() function works", {
11 |
12 |
13 | dsa <- dsattr(class = "character", label = "My label", description = "Desc",
14 | format = "%s", width = 8, justify = "left", fork = "hi",
15 | bork = "bye")
16 |
17 | expect_equal(dsa$class, "character")
18 | expect_equal(dsa$label, "My label")
19 | expect_equal(dsa$description, "Desc")
20 | expect_equal(dsa$format, "%s")
21 | expect_equal(dsa$width, 8)
22 | expect_equal(dsa$justify, "left")
23 | expect_equal(dsa$fork, "hi")
24 | expect_equal(dsa$bork, "bye")
25 |
26 | })
27 |
28 |
29 |
30 |
31 | test_that("dsattr function works with datastep and new variable.", {
32 |
33 | dsa <- dsattr(class = "character", label = "My label", description = "Desc",
34 | format = "%s", width = 8, justify = "left", fork = "hi",
35 | bork = "bye")
36 |
37 |
38 | dat <- mtcars[1:10, ]
39 |
40 | attr(dat$mpg, "label") <- "Miles Per Gallon"
41 |
42 | expect_equal(attr(dat$mpg, "label"), "Miles Per Gallon")
43 |
44 |
45 | d1 <- datastep(dat, attrib = list(fork = dsa), {
46 |
47 | fork <- "Hello"
48 |
49 | })
50 |
51 | attributes(d1$mpg)
52 | attributes(d1$fork)
53 |
54 |
55 | expect_equal("fork" %in% names(d1), TRUE)
56 | expect_equal(class(d1[["fork"]]), "character")
57 | expect_equal(attr(d1[["fork"]], "label"), "My label")
58 | expect_equal(attr(d1[["fork"]], "description"), "Desc")
59 | expect_equal(attr(d1[["fork"]], "format"), "%s")
60 | expect_equal(attr(d1[["fork"]], "width"), 8)
61 | expect_equal(attr(d1[["fork"]], "justify"), "left")
62 | expect_equal(attr(d1[["fork"]], "fork"), "hi")
63 | expect_equal(attr(d1[["fork"]], "bork"), "bye")
64 | expect_equal(attr(d1[["mpg"]], "label"), "Miles Per Gallon")
65 | })
66 |
67 |
68 |
69 |
70 | test_that("dsattr function works with datastep and two new variables.", {
71 |
72 | dsa1 <- dsattr(class = "character", label = "My label1")
73 | dsa2 <- dsattr(class = "character", label = "My label2", format = "%1.1f")
74 |
75 |
76 | dat <- mtcars[1:10, ]
77 |
78 | attr(dat$mpg, "label") <- "Miles Per Gallon"
79 |
80 | expect_equal(attr(dat$mpg, "label"), "Miles Per Gallon")
81 |
82 |
83 | d1 <- datastep(dat, attrib = list(fork = dsa1, bork = dsa2), {
84 |
85 | fork <- "Hello"
86 | bork <- "Goodbye"
87 |
88 | })
89 |
90 | attributes(d1$fork)
91 | attributes(d1$bork)
92 |
93 | d1
94 |
95 |
96 | expect_equal("fork" %in% names(d1), TRUE)
97 | expect_equal("bork" %in% names(d1), TRUE)
98 | expect_equal(attr(d1[["fork"]], "label"), "My label1")
99 | expect_equal(attr(d1[["bork"]], "label"), "My label2")
100 | expect_equal(attr(d1[["mpg"]], "label"), "Miles Per Gallon")
101 | expect_equal(attr(d1[["bork"]], "format"), "%1.1f")
102 | })
103 |
104 |
105 | test_that("dsattr function works with datastep and a tibble.", {
106 |
107 | library(tibble)
108 |
109 | dsa1 <- dsattr(class = "character", label = "My label1")
110 | dsa2 <- dsattr(class = "character", label = "My label2")
111 |
112 |
113 | dat <- as_tibble(mtcars[1:10, ])
114 |
115 | attr(dat$mpg, "label") <- "Miles Per Gallon"
116 |
117 | expect_equal(attr(dat$mpg, "label"), "Miles Per Gallon")
118 |
119 |
120 | d1 <- datastep(dat, attrib = list(fork = dsa1, bork = dsa2), {
121 |
122 | fork <- "Hello"
123 | bork <- "Goodbye"
124 |
125 | })
126 |
127 | attributes(d1$fork)
128 | attributes(d1$bork)
129 |
130 | d1
131 |
132 |
133 | expect_equal("fork" %in% names(d1), TRUE)
134 | expect_equal("bork" %in% names(d1), TRUE)
135 | expect_equal(attr(d1[["fork"]], "label"), "My label1")
136 | expect_equal(attr(d1[["bork"]], "label"), "My label2")
137 | expect_equal(attr(d1[["mpg"]], "label"), "Miles Per Gallon")
138 | })
139 |
140 |
141 | test_that("attrib parameter works with datastep and no dsattr.", {
142 |
143 |
144 |
145 | dat <- mtcars[1:10, ]
146 |
147 |
148 | d1 <- datastep(dat, attrib = list(fork = "", bork = 0), {
149 |
150 |
151 | })
152 |
153 | attributes(d1$fork)
154 | attributes(d1$bork)
155 |
156 | d1
157 |
158 |
159 | expect_equal("fork" %in% names(d1), TRUE)
160 | expect_equal("bork" %in% names(d1), TRUE)
161 | expect_equal(d1[["fork"]][1], "")
162 | expect_equal(d1[["bork"]][1], 0)
163 |
164 |
165 |
166 | d2 <- datastep(dat, attrib = list(fork = "hello", bork = 23), {
167 |
168 |
169 | })
170 |
171 |
172 | d2
173 |
174 |
175 | expect_equal("fork" %in% names(d2), TRUE)
176 | expect_equal("bork" %in% names(d2), TRUE)
177 | expect_equal(d2[["fork"]][1], "hello")
178 | expect_equal(d2[["bork"]][1], 23)
179 |
180 | })
181 |
182 |
183 | test_that("dsattr function works with datastep and calculated variable.", {
184 |
185 | dsa <- dsattr(class = "character", label = "My label", description = "Desc",
186 | format = "%s", width = 8, justify = "left", fork = "hi",
187 | bork = "bye")
188 |
189 |
190 | dat <- mtcars[1:10, ]
191 |
192 | attr(dat$mpg, "label") <- "Miles Per Gallon"
193 |
194 | expect_equal(attr(dat$mpg, "label"), "Miles Per Gallon")
195 |
196 |
197 | d1 <- datastep(dat, attrib = list(fork = dsa),
198 | calculate = {fork = 1}, {
199 |
200 | })
201 |
202 | attributes(d1$mpg)
203 | attributes(d1$fork)
204 |
205 |
206 | expect_equal("fork" %in% names(d1), TRUE)
207 | expect_equal(class(d1[["fork"]]), "numeric")
208 | expect_equal(attr(d1[["fork"]], "label"), "My label")
209 | expect_equal(attr(d1[["fork"]], "description"), "Desc")
210 | expect_equal(attr(d1[["fork"]], "format"), "%s")
211 | expect_equal(attr(d1[["fork"]], "width"), 8)
212 | expect_equal(attr(d1[["fork"]], "justify"), "left")
213 | expect_equal(attr(d1[["fork"]], "fork"), "hi")
214 | expect_equal(attr(d1[["fork"]], "bork"), "bye")
215 | expect_equal(attr(d1[["mpg"]], "label"), "Miles Per Gallon")
216 | })
217 |
218 |
219 |
220 |
--------------------------------------------------------------------------------
/vignettes/libr-management.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Library Management"
3 | output: rmarkdown::html_vignette
4 | vignette: >
5 | %\VignetteIndexEntry{Library Management}
6 | %\VignetteEngine{knitr::rmarkdown}
7 | %\VignetteEncoding{UTF-8}
8 | ---
9 |
10 | ```{r setup, include = FALSE}
11 | knitr::opts_chunk$set(
12 | collapse = TRUE,
13 | comment = "#>"
14 | )
15 | ```
16 |
17 | The **libr** package also contains a number of functions for managing
18 | data libraries. There are functions to add and remove data from a library,
19 | as well as copy or delete an entire library.
20 |
21 | The example below illustrates some of these management functions. The example
22 | first creates a library and adds some data to it. The example then proceeds
23 | to copy it to another library and perform some manipulation of the data
24 | in the libraries. The example ends by looking at some of the metadata
25 | available for libraries:
26 |
27 | ```{r eval=FALSE, echo=TRUE}
28 | library(libr)
29 |
30 | # Create temp directory
31 | tmp <- tempdir()
32 |
33 | # Create libraries
34 | libname(s1, tmp)
35 |
36 | # Add data to library and adjust names
37 | lib_add(s1, state.name, state.area, state.region, state.abb,
38 | name = c("name", "area", "region", "abb"))
39 | # # library 's1': 4 items
40 | # - attributes: rds not loaded
41 | # - path: C:\Users\User\AppData\Local\Temp\RtmpqAMV6L
42 | # - items:
43 | # Name Extension Rows Cols Size LastModified
44 | # 1 name rds 50 1 4.4 Kb 2020-11-29 17:00:28
45 | # 2 area rds 50 1 1.4 Kb 2020-11-29 17:00:28
46 | # 3 region rds 50 1 1.9 Kb 2020-11-29 17:00:28
47 | # 4 abb rds 50 1 4.1 Kb 2020-11-29 17:00:28
48 |
49 | # Copy library to backup location
50 | lib_copy(s1, s2, file.path(tmp, "orig"))
51 | # # library 's2': 4 items
52 | # - attributes: rds not loaded
53 | # - path: C:\Users\User\AppData\Local\Temp\RtmpqAMV6L/orig
54 | # - items:
55 | # Name Extension Rows Cols Size LastModified
56 | # 1 name rds 50 1 4.4 Kb 2020-11-29 17:01:17
57 | # 2 area rds 50 1 1.4 Kb 2020-11-29 17:01:17
58 | # 3 region rds 50 1 1.9 Kb 2020-11-29 17:01:17
59 | # 4 abb rds 50 1 4.1 Kb 2020-11-29 17:01:17
60 |
61 | # Remove data from library 1
62 | lib_remove(s1, name = c("name", "area", "region", "abb"))
63 | # # library 's1': 0 items
64 | # - attributes: rds not loaded
65 | # - path: C:\Users\User\AppData\Local\Temp\RtmpqAMV6L
66 | # NULL
67 |
68 | # Load library 1 into memory
69 | lib_load(s1)
70 |
71 | s1.combined <- data.frame(name = s2.name, abb = s2.abb,
72 | area = s2.area, region = s2.region,
73 | stringsAsFactors = FALSE)
74 |
75 | s1.east <- subset(s1.combined, region == "Northeast")
76 | s1.west <- subset(s1.combined, region == "West")
77 | s1.north <- subset(s1.combined, region == "North Central")
78 | s1.south <- subset(s1.combined, region == "South")
79 |
80 | # Sync workspace with library list
81 | lib_sync(s1)
82 | # # library 's1': 5 items
83 | # - attributes: rds loaded
84 | # - path: C:\Users\User\AppData\Local\Temp\RtmpqAMV6L
85 | # - items:
86 | # Name Extension Rows Cols Size LastModified
87 | # 1 combined NA 50 4 12.7 Kb
88 | # 2 east NA 9 4 3.2 Kb
89 | # 3 north NA 12 4 3.5 Kb
90 | # 4 south NA 16 4 4 Kb
91 | # 5 west NA 13 4 3.6 Kb
92 |
93 | # Save library 1 to disk
94 | lib_write(s1)
95 | # # library 's1': 5 items
96 | # - attributes: rds loaded
97 | # - path: C:\Users\User\AppData\Local\Temp\RtmpqAMV6L
98 | # - items:
99 | # Name Extension Rows Cols Size LastModified
100 | # 1 combined rds 50 4 13.4 Kb 2020-11-29 17:03:40
101 | # 2 east rds 9 4 4 Kb 2020-11-29 17:03:40
102 | # 3 north rds 12 4 4.3 Kb 2020-11-29 17:03:40
103 | # 4 south rds 16 4 4.8 Kb 2020-11-29 17:03:40
104 | # 5 west rds 13 4 4.4 Kb 2020-11-29 17:03:40
105 |
106 | # View path
107 | lib_path(s1)
108 | # [1] "C:\\Users\\User\\AppData\\Local\\Temp\\RtmpqAMV6L"
109 |
110 | # View size
111 | lib_size(s1)
112 | # [1] 7175
113 |
114 | # View info
115 | lib_info(s1)
116 | # Name Extension Rows Cols Size LastModified
117 | # 1 combined rds 50 4 13.4 Kb 2020-11-29 17:03:40
118 | # 2 east rds 9 4 4 Kb 2020-11-29 17:03:40
119 | # 3 north rds 12 4 4.3 Kb 2020-11-29 17:03:40
120 | # 4 south rds 16 4 4.8 Kb 2020-11-29 17:03:40
121 | # 5 west rds 13 4 4.4 Kb 2020-11-29 17:03:40
122 |
123 | # Display dictionary
124 | dictionary(s1)
125 | # # A tibble: 20 x 10
126 | # Name Column Class Label Description Format Width Justify Rows NAs
127 | #
128 | # 1 combined name character NA NA NA 14 NA 50 0
129 | # 2 combined abb character NA NA NA 2 NA 50 0
130 | # 3 combined area numeric NA NA NA NA NA 50 0
131 | # 4 combined region factor NA NA NA NA NA 50 0
132 | # 5 east name character NA NA NA 13 NA 9 0
133 | # 6 east abb character NA NA NA 2 NA 9 0
134 | # 7 east area numeric NA NA NA NA NA 9 0
135 | # 8 east region factor NA NA NA NA NA 9 0
136 | # 9 north name character NA NA NA 12 NA 12 0
137 | # 10 north abb character NA NA NA 2 NA 12 0
138 | # 11 north area numeric NA NA NA NA NA 12 0
139 | # 12 north region factor NA NA NA NA NA 12 0
140 | # 13 south name character NA NA NA 14 NA 16 0
141 | # 14 south abb character NA NA NA 2 NA 16 0
142 | # 15 south area numeric NA NA NA NA NA 16 0
143 | # 16 south region factor NA NA NA NA NA 16 0
144 | # 17 west name character NA NA NA 10 NA 13 0
145 | # 18 west abb character NA NA NA 2 NA 13 0
146 | # 19 west area numeric NA NA NA NA NA 13 0
147 | # 20 west region factor NA NA NA NA NA 13 0
148 |
149 | # Unload library 1
150 | lib_unload(s1)
151 |
152 | # Clean up
153 | lib_delete(s1)
154 | lib_delete(s2)
155 | ```
156 |
157 |
158 | Next: [Data Step Operations](libr-datastep.html)
159 |
--------------------------------------------------------------------------------
/tests/testthat/test-dictionary.R:
--------------------------------------------------------------------------------
1 | context("Dictionary Tests")
2 |
3 | base_path <- "c:\\packages\\libr\\tests\\testthat\\data"
4 |
5 | base_path <- "./data"
6 |
7 | dev <- FALSE
8 |
9 | test_that("dict1: getDictionary() function works as expected.", {
10 |
11 | crs <- data.frame(name = rownames(mtcars), mtcars, stringsAsFactors = FALSE)
12 |
13 | attr(crs$name, "label") <- "Car Name"
14 | attr(crs$name, "description") <- "Derived from rownames"
15 | crs$type <- ifelse(crs$mpg > 20, "High", "Low")
16 | attr(crs$mpg, "format") <- "%.1f"
17 |
18 | res <- getDictionary(crs, "crs")
19 |
20 | expect_equal(nrow(res), 13)
21 | expect_equal(as.character(res[1, "Label"]), "Car Name")
22 | expect_equal(as.character(res[1, "Description"]), "Derived from rownames")
23 | expect_equal(res[13, "MaxChar"], 4)
24 |
25 | })
26 |
27 |
28 |
29 | test_that("dict2: dictionary() function works as expected with df.", {
30 |
31 | crs <- data.frame(name = rownames(mtcars), mtcars, stringsAsFactors = FALSE)
32 |
33 | attr(crs$name, "label") <- "Car Name"
34 | attr(crs$name, "description") <- "Derived from rownames"
35 | crs$type <- ifelse(crs$mpg > 20, "High", "Low")
36 | attr(crs$mpg, "format") <- "%.1f"
37 |
38 | res <- dictionary(crs)
39 |
40 | expect_equal(nrow(res), 13)
41 |
42 | })
43 |
44 |
45 |
46 | test_that("dict3: dictionary() function works as expected with tibble.", {
47 |
48 | library(tibble)
49 |
50 | crs <- tibble(name = rownames(mtcars), mtcars)
51 |
52 | attr(crs$name, "label") <- "Car Name"
53 | attr(crs$name, "description") <- "Derived from rownames"
54 | crs$type <- ifelse(crs$mpg > 20, "High", "Low")
55 | attr(crs$mpg, "format") <- "%.1f"
56 | attr(crs$hp, "justify") <- "left"
57 |
58 | res <- dictionary(crs)
59 |
60 | expect_equal(nrow(res), 13)
61 |
62 | })
63 |
64 |
65 | test_that("dict4: dictionary() function works as expected with lib.", {
66 |
67 | crs <- data.frame(name = rownames(mtcars), mtcars, stringsAsFactors = FALSE)
68 |
69 | attr(crs$name, "label") <- "Car Name"
70 | attr(crs$name, "description") <- "Derived from rownames"
71 | crs$type <- ifelse(crs$mpg > 20, "High", "Low")
72 | attr(crs$mpg, "format") <- "%.1f"
73 | attr(crs$name, "justify") <- "left"
74 |
75 | dat <- libname(dat, tempdir())
76 |
77 | dat <- lib_add(dat, crs)
78 | dat <- lib_add(dat, iris)
79 | dat <- lib_add(dat, beaver1)
80 |
81 | res <- dictionary(dat)
82 |
83 | expect_equal(nrow(res), 22)
84 |
85 |
86 | lib_delete(dat)
87 | })
88 |
89 |
90 |
91 | test_that("dict5: dictionary() function works as expected with df and standard_eval.", {
92 |
93 |
94 | options("libr.standard_eval" = TRUE)
95 |
96 | crs <- data.frame(name = rownames(mtcars), mtcars, stringsAsFactors = FALSE)
97 |
98 | attr(crs$name, "label") <- "Car Name"
99 | attr(crs$name, "description") <- "Derived from rownames"
100 | crs$type <- ifelse(crs$mpg > 20, "High", "Low")
101 | attr(crs$mpg, "format") <- "%.1f"
102 |
103 | res <- dictionary(crs)
104 |
105 | expect_equal(nrow(res), 13)
106 |
107 | options("libr.standard_eval" = FALSE)
108 |
109 | })
110 |
111 |
112 | test_that("dict6: dictionary() function works as expected with lib.", {
113 |
114 | options("libr.standard_eval" = TRUE)
115 |
116 | crs <- data.frame(name = rownames(mtcars), mtcars, stringsAsFactors = FALSE)
117 |
118 | attr(crs$name, "label") <- "Car Name"
119 | attr(crs$name, "description") <- "Derived from rownames"
120 | crs$type <- ifelse(crs$mpg > 20, "High", "Low")
121 | attr(crs$mpg, "format") <- "%.1f"
122 | attr(crs$name, "justify") <- "left"
123 |
124 | dat <- libname(dat, tempdir())
125 |
126 | dat <- lib_add(dat, crs)
127 | dat <- lib_add(dat, iris)
128 | dat <- lib_add(dat, beaver1)
129 |
130 | res <- dictionary(dat)
131 |
132 | res
133 | expect_equal(nrow(res), 22)
134 |
135 |
136 | lib_delete(dat)
137 |
138 | options("libr.standard_eval" = FALSE)
139 | })
140 |
141 |
142 | test_that("dict7: dictionary() parameter checks work as expected.", {
143 |
144 | f <- "fork"
145 |
146 | expect_error(dictionary(f))
147 |
148 |
149 | })
150 |
151 | test_that("dict8: dictionary() widths work as expected when width attribute set.", {
152 |
153 | crs <- data.frame(name = rownames(mtcars), mtcars, fork = "fork",
154 | stringsAsFactors = FALSE)
155 |
156 | attr(crs$name, "width") <- 4
157 | attr(crs$name, "description") <- "Derived from rownames"
158 |
159 |
160 | res <- dictionary(crs)
161 |
162 | res
163 |
164 | expect_equal(res$Width[1], 4)
165 | expect_equal(is.na(res$Width[13]), TRUE)
166 |
167 | })
168 |
169 | test_that("dict9: dictionary() widths work as expected when width attribute not set.", {
170 |
171 | crs <- data.frame(name = rownames(mtcars), mtcars, fork = "fork",
172 | stringsAsFactors = FALSE)
173 |
174 | #attr(crs$name, "width") <- 4
175 | attr(crs$name, "description") <- "Derived from rownames"
176 |
177 |
178 | res <- dictionary(crs)
179 |
180 | res
181 |
182 | expect_equal(is.na(res$Width[1]), TRUE)
183 | expect_equal(is.na(res$Width[13]), TRUE)
184 | expect_equal(res$MaxChar[1], 19)
185 | expect_equal(res$MaxChar[13], 4)
186 |
187 | })
188 |
189 | test_that("dict10: dictionary() function works as expected with user-defined format.", {
190 |
191 | if (dev) {
192 |
193 | library(fmtr)
194 |
195 | fmt <- value(condition(x == 4, "A"),
196 | condition(x == 8, "B"),
197 | condition(TRUE, "C"))
198 |
199 |
200 | crs <- data.frame(name = rownames(mtcars), mtcars, stringsAsFactors = FALSE)
201 |
202 | fapply(crs$cyl, fmt)
203 |
204 | attr(crs$cyl, "format") <- fmt
205 |
206 | # Shouldn't get an error
207 | res <- dictionary(crs)
208 |
209 | expect_equal(nrow(res), 12)
210 |
211 | } else
212 | expect_equal(TRUE, TRUE)
213 |
214 | })
215 |
216 | test_that("dict11: dictionary() function works with standard libname.", {
217 |
218 |
219 | if (dev) {
220 | libname(tst, file.path(base_path, "SDTM"), "csv")
221 |
222 | # Shouldn't get error here.
223 | d <- dictionary(tst)
224 |
225 |
226 | d
227 |
228 | }
229 |
230 | expect_equal(TRUE, TRUE)
231 |
232 | })
233 |
234 | test_that("dict12: dictionary() function has no errors if data frame has no rows.", {
235 |
236 | crs <- data.frame(name = rownames(mtcars), mtcars, stringsAsFactors = FALSE)
237 |
238 | attr(crs$name, "label") <- "Car Name"
239 | attr(crs$name, "description") <- "Derived from rownames"
240 | crs$type <- ifelse(crs$mpg > 20, "High", "Low")
241 | attr(crs$mpg, "format") <- "%.1f"
242 |
243 | res <- dictionary(crs[0, ])
244 |
245 | expect_equal(nrow(res), 13)
246 |
247 | })
248 |
249 |
250 |
--------------------------------------------------------------------------------