Skip to contents

Document the key attributes surveys in a survey list.

Usage

document_surveys(survey_list = NULL, survey_paths = NULL, .f = NULL)

document_waves(waves)

Arguments

survey_list

A list of survey objects.

survey_paths

A vector of full file paths to the surveys to subset, defaults to NULL.

.f

A function to import the surveys with. Defaults to 'read_rds'. For SPSS files, read_spss is recommended, which is a well-parameterized version of read_spss that saves some metadata, too. For STATA files use read_dta.

waves

A list of survey objects.

Value

Returns a data frame with the key attributes of the surveys in a survey list: the name of the data file, the number of rows and columns, and the size of the object as stored in memory.

Details

The function has two alternative input parameters. If survey_list is the input, it returns the name of the original source data file, the number of rows and columns, and the size of the object as stored in memory. In case survey_paths contains the source data files, it will sequentially read those files, and add the file size, the last access and the last modified time attributes.

The earlier form document_waves is deprecated. Currently called document_surveys.

See also

Other documentation functions: document_survey_item()

Examples

examples_dir <- system.file( "examples", package = "retroharmonize")
                        
my_rds_files <- dir( examples_dir)[grepl(".rds", 
                                   dir(examples_dir))]

example_surveys <- read_surveys(file.path(examples_dir, my_rds_files))
 
documented_surveys <- document_surveys(survey_list=example_surveys)

attr(documented_surveys, "original_list")
#> [1] "example_surveys"
documented_surveys
#> # A tibble: 3 × 5
#>   id     filename    ncol  nrow object_size
#>   <chr>  <chr>      <int> <int>       <dbl>
#> 1 ZA5913 ZA5913.rds    37    35      108664
#> 2 ZA6863 ZA6863.rds    48    50      143200
#> 3 ZA7576 ZA7576.rds    55    45      164128

document_surveys(survey_paths = file.path(examples_dir, my_rds_files))
#> 1/1 ZA5913.rds
#> 1/2 ZA6863.rds
#> 1/3 ZA7576.rds
#> # A tibble: 3 × 8
#>   id     filename    ncol  nrow object_size file_size accessed    last_modified 
#>   <chr>  <chr>      <dbl> <dbl>       <dbl>     <dbl> <chr>       <chr>         
#> 1 ZA5913 ZA5913.rds    37    35      108664      6507 2022-01-12… 2022-01-12 09…
#> 2 ZA6863 ZA6863.rds    48    50      143200      8738 2022-01-12… 2022-01-12 09…
#> 3 ZA7576 ZA7576.rds    55    45      164128      9312 2022-01-12… 2022-01-12 09…