Skip to contents

Data set to data dictionary function

Usage

ds2dd(
  ds,
  record.id = "record_id",
  form.name = "basis",
  field.type = "text",
  field.label = NULL,
  include.column.names = FALSE
)

Arguments

ds

data set

record.id

name or column number of id variable, moved to first row of data dictionary, character of integer. Default is "record_id".

form.name

vector of form names, character string, length 1 or length equal to number of variables. Default is "basis".

field.type

vector of field types, character string, length 1 or length equal to number of variables. Default is "text.

field.label

vector of form names, character string, length 1 or length equal to number of variables. Default is NULL and is then identical to field names.

include.column.names

Flag to give detailed output including new column names for original data set for upload.

Value

data.frame or list of data.frame and vector

Examples

talos$id <- seq_len(nrow(talos))
ds2dd(talos, record.id="id",include.column.names=FALSE)
#>     field_name form_name section_header field_type  field_label
#> 1           id     basis             NA       text           id
#> 2       rtreat     basis             NA       text       rtreat
#> 3        mrs_1     basis             NA       text        mrs_1
#> 4        mrs_6     basis             NA       text        mrs_6
#> 5 hypertension     basis             NA       text hypertension
#> 6     diabetes     basis             NA       text     diabetes
#> 7        civil     basis             NA       text        civil
#>   select_choices_or_calculations field_note
#> 1                             NA         NA
#> 2                             NA         NA
#> 3                             NA         NA
#> 4                             NA         NA
#> 5                             NA         NA
#> 6                             NA         NA
#> 7                             NA         NA
#>   text_validation_type_or_show_slider_number text_validation_min
#> 1                                         NA                  NA
#> 2                                         NA                  NA
#> 3                                         NA                  NA
#> 4                                         NA                  NA
#> 5                                         NA                  NA
#> 6                                         NA                  NA
#> 7                                         NA                  NA
#>   text_validation_max identifier branching_logic required_field
#> 1                  NA         NA              NA             NA
#> 2                  NA         NA              NA             NA
#> 3                  NA         NA              NA             NA
#> 4                  NA         NA              NA             NA
#> 5                  NA         NA              NA             NA
#> 6                  NA         NA              NA             NA
#> 7                  NA         NA              NA             NA
#>   custom_alignment question_number matrix_group_name matrix_ranking
#> 1               NA              NA                NA             NA
#> 2               NA              NA                NA             NA
#> 3               NA              NA                NA             NA
#> 4               NA              NA                NA             NA
#> 5               NA              NA                NA             NA
#> 6               NA              NA                NA             NA
#> 7               NA              NA                NA             NA
#>   field_annotation
#> 1               NA
#> 2               NA
#> 3               NA
#> 4               NA
#> 5               NA
#> 6               NA
#> 7               NA