Create PsychDS Codebook from Data

codebook(
  data,
  name = NULL,
  vardesc = list(),
  ...,
  schemaVersion = "Psych-DS 0.1.0",
  return = "json",
  interactive = FALSE
)

Arguments

data

The data frame to generate a codebook for

name

The name of this dataset (if NULL, will be the same as data)

vardesc

Optional variable properties in the format of a named list of vectors (can be named or unnamed and in the same order as the data) from the options description, privacy, type, propertyID, minValue, maxValue, levels, ordered, na, naValues, alternateName, unitCode

...

Further dataset properties (e.g., description, license, author, citation, funder, url, doi/sameAs, keywords, temporalCoverage, spatialCoverage, datePublished, dateCreated)

schemaVersion

defaults to "Psych-DS 0.1.0"

return

Whether the output should be in JSON format (json), a list (list) or the reformatted data with the codebook as an attribute (data)

interactive

Whether the function should prompt the user to describe columns and factor levels

Value

a list or json-formatted codebook, or reformatted data withthe codebook as an attribute

Examples


vardesc = list(
  description = c(speed = "Speed",
                  dist = "Stopping distance" ),
  type = c("float", "float"),
  unitText = c(speed = "mph", dist = "ft")
)
codebook(cars, vardesc = vardesc)
#> Warning: The following variable properties are not standard: type
#> speed set to dataType int
#> dist set to dataType int
#> {
#>     "@context": "https://schema.org/",
#>     "@type": "Dataset",
#>     "name": "cars",
#>     "schemaVersion": "Psych-DS 0.1.0",
#>     "variableMeasured": [
#>         {
#>             "@type": "PropertyValue",
#>             "name": "speed",
#>             "description": "Speed",
#>             "type": "float",
#>             "unitText": "mph",
#>             "dataType": "int"
#>         },
#>         {
#>             "@type": "PropertyValue",
#>             "name": "dist",
#>             "description": "Stopping distance",
#>             "type": "float",
#>             "unitText": "ft",
#>             "dataType": "int"
#>         }
#>     ]
#> }
#>  
codebook(cars, vardesc = vardesc, return = "list")
#> Warning: The following variable properties are not standard: type
#> speed set to dataType int
#> dist set to dataType int
#> Codebook for cars (Psych-DS 0.1.0)
#> 
#> Dataset Parameters
#> 
#> * name: cars
#> * schemaVersion: Psych-DS 0.1.0
#> 
#> Column Parameters
#> 
#> * speed (int): Speed
#> * dist (int): Stopping distance