2023-02-28 13:59:45 +01:00
|
|
|
% Generated by roxygen2: do not edit by hand
|
|
|
|
% Please edit documentation in R/redcap_wider.R
|
|
|
|
\name{redcap_wider}
|
|
|
|
\alias{redcap_wider}
|
|
|
|
\title{Redcap Wider}
|
|
|
|
\usage{
|
2023-03-07 15:38:28 +01:00
|
|
|
redcap_wider(
|
2024-02-06 14:01:03 +01:00
|
|
|
data,
|
2023-03-07 15:38:28 +01:00
|
|
|
event.glue = "{.value}_{redcap_event_name}",
|
|
|
|
inst.glue = "{.value}_{redcap_repeat_instance}"
|
|
|
|
)
|
2023-02-28 13:59:45 +01:00
|
|
|
}
|
|
|
|
\arguments{
|
2024-02-06 14:01:03 +01:00
|
|
|
\item{data}{A list of data frames.}
|
2023-02-28 13:59:45 +01:00
|
|
|
|
2023-03-07 15:38:28 +01:00
|
|
|
\item{event.glue}{A dplyr::glue string for repeated events naming}
|
|
|
|
|
|
|
|
\item{inst.glue}{A dplyr::glue string for repeated instruments naming}
|
2023-02-28 13:59:45 +01:00
|
|
|
}
|
|
|
|
\value{
|
|
|
|
The list of data frames in wide format.
|
|
|
|
}
|
|
|
|
\description{
|
|
|
|
Converts a list of REDCap data frames from long to wide format.
|
2023-03-07 15:38:28 +01:00
|
|
|
Handles longitudinal projects, but not yet repeated instruments.
|
2023-02-28 13:59:45 +01:00
|
|
|
}
|
|
|
|
\examples{
|
2024-02-06 14:01:03 +01:00
|
|
|
# Longitudinal
|
|
|
|
list1 <- list(data.frame(record_id = c(1,2,1,2),
|
2023-02-28 13:59:45 +01:00
|
|
|
redcap_event_name = c("baseline", "baseline", "followup", "followup"),
|
|
|
|
age = c(25,26,27,28)),
|
|
|
|
data.frame(record_id = c(1,2),
|
|
|
|
redcap_event_name = c("baseline", "baseline"),
|
|
|
|
gender = c("male", "female")))
|
2024-02-06 14:01:03 +01:00
|
|
|
redcap_wider(list1)
|
|
|
|
# Simpel with two instruments
|
|
|
|
list2 <- list(data.frame(record_id = c(1,2),
|
|
|
|
age = c(25,26)),
|
|
|
|
data.frame(record_id = c(1,2),
|
|
|
|
gender = c("male", "female")))
|
|
|
|
redcap_wider(list2)
|
|
|
|
# Simple with single instrument
|
|
|
|
list3 <- list(data.frame(record_id = c(1,2),
|
|
|
|
age = c(25,26)))
|
|
|
|
redcap_wider(list3)
|
|
|
|
# Longitudinal with repeatable instruments
|
|
|
|
list4 <- list(data.frame(record_id = c(1,2,1,2),
|
|
|
|
redcap_event_name = c("baseline", "baseline", "followup", "followup"),
|
|
|
|
age = c(25,26,27,28)),
|
|
|
|
data.frame(record_id = c(1,1,1,1,2,2,2,2),
|
|
|
|
redcap_event_name = c("baseline", "baseline", "followup", "followup",
|
|
|
|
"baseline", "baseline", "followup", "followup"),
|
|
|
|
redcap_repeat_instrument = "walk",
|
|
|
|
redcap_repeat_instance=c(1,2,1,2,1,2,1,2),
|
|
|
|
dist = c(40, 32, 25, 33, 28, 24, 23, 36)),
|
|
|
|
data.frame(record_id = c(1,2),
|
|
|
|
redcap_event_name = c("baseline", "baseline"),
|
|
|
|
gender = c("male", "female")))
|
|
|
|
redcap_wider(list4)
|
2023-02-28 13:59:45 +01:00
|
|
|
}
|