format_record {REDCapExporter}R Documentation

Format Record

Description

Use REDCap project metadata to build a well formatted data.frame for the record.

Usage

format_record(x, metadata = NULL, col_type = NULL, class = "data.table", ...)

Arguments

x

a rcer_rccore, rcer_raw_record, or rcer_record object.

metadata

a rcer_metadata or rcer_raw_metadata object. Will be ignored if col_type is defined.

col_type

a rcer_col_type object.

class

return either a data.frame or data.table

...

other arguments passed to col_type

Value

A data.frame or data.table

See Also

export_core

Examples


data("avs_raw_metadata")
data("avs_raw_record")

avs <- format_record(avs_raw_record, avs_raw_metadata, class = "data.frame")
avs

avs <- format_record(avs_raw_core, class = "data.frame")
head(avs)

avs <- format_record(avs_raw_core, class = "data.table")
avs$atoi
as.numeric(avs$atoi)
avs[, `:=`(atoi_seconds = as.numeric(atoi),
           atoi_seconds_postseason = as.numeric(atoi_postseason),
           atoi = as.character(atoi),
           atoi_postseason = as.character(atoi_postseason))]
avs[, .SD, .SDcols = patterns("atoi")]


[Package REDCapExporter version 0.2.2 Index]