This commit is contained in:
Andreas Gammelgaard Damsbo 2024-02-27 13:20:21 +01:00
commit 9e33057c06
32 changed files with 456 additions and 340 deletions

View file

@ -50,19 +50,19 @@ library(RCurl)
# Get the records
records <- postForm(
uri = api_url, # Supply your site-specific URI
uri = api_url, # Supply your site-specific URI
token = api_token, # Supply your own API token
content = 'record',
format = 'json',
returnFormat = 'json'
content = "record",
format = "json",
returnFormat = "json"
)
# Get the metadata
metadata <- postForm(
uri = api_url, # Supply your site-specific URI
uri = api_url, # Supply your site-specific URI
token = api_token, # Supply your own API token
content = 'metadata',
format = 'json'
content = "metadata",
format = "json"
)
# Convert exported JSON strings into a list of data.frames
@ -75,7 +75,8 @@ records <- read.csv("/path/to/data/ExampleProject_DATA_2018-06-03_1700.csv")
# Get the metadata
metadata <- read.csv(
"/path/to/data/ExampleProject_DataDictionary_2018-06-03.csv")
"/path/to/data/ExampleProject_DataDictionary_2018-06-03.csv"
)
# Split the tables
REDCapRITS::REDCap_split(records, metadata)

View file

@ -44,8 +44,8 @@ data set (imported .dta file with `haven::read_dta()`. Default is "label"}
\item{field.validation}{manually specify field validation(s). Vector of
length 1 or ncol(data). Default is NULL and `levels()` are used for factors
or attribute `factor.labels.attr` for haven_labelled data set (imported .dta file with
`haven::read_dta()`).}
or attribute `factor.labels.attr` for haven_labelled data set (imported .dta
file with `haven::read_dta()`).}
\item{metadata}{redcap metadata headings. Default is
REDCapCAST:::metadata_names.}

View file

@ -32,5 +32,7 @@ has to be converted to character class before REDCap upload.
\examples{
data <- redcapcast_data
data |> guess_time_only_filter()
data |> guess_time_only_filter(validate = TRUE) |> lapply(head)
data |>
guess_time_only_filter(validate = TRUE) |>
lapply(head)
}

View file

@ -2,7 +2,8 @@
% Please edit documentation in R/read_redcap_instrument.R
\name{read_redcap_instrument}
\alias{read_redcap_instrument}
\title{Convenience function to download complete instrument, using token storage in keyring.}
\title{Convenience function to download complete instrument, using token storage
in keyring.}
\usage{
read_redcap_instrument(
key,
@ -24,11 +25,13 @@ read_redcap_instrument(
\item{id_name}{id variable name. Default is "record_id".}
\item{records}{specify the records to download. Index numbers. Numeric vector.}
\item{records}{specify the records to download. Index numbers.
Numeric vector.}
}
\value{
data.frame
}
\description{
Convenience function to download complete instrument, using token storage in keyring.
Convenience function to download complete instrument, using token storage
in keyring.
}

View file

@ -26,35 +26,59 @@ Handles longitudinal projects, but not yet repeated instruments.
}
\examples{
# Longitudinal
list1 <- 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,2),
redcap_event_name = c("baseline", "baseline"),
gender = c("male", "female")))
list1 <- 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, 2),
redcap_event_name = c("baseline", "baseline"),
gender = c("male", "female")
)
)
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")))
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)))
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")))
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)
}

View file

@ -12,9 +12,11 @@ A data frame with 22 variables:
\item{section_header}{section_header, character}
\item{field_type}{field_type, character}
\item{field_label}{field_label, character}
\item{select_choices_or_calculations}{select_choices_or_calculations, character}
\item{select_choices_or_calculations}
{select_choices_or_calculations, character}
\item{field_note}{field_note, character}
\item{text_validation_type_or_show_slider_number}{text_validation_type_or_show_slider_number, character}
\item{text_validation_type_or_show_slider_number}
{text_validation_type_or_show_slider_number, character}
\item{text_validation_min}{text_validation_min, character}
\item{text_validation_max}{text_validation_max, character}
\item{identifier}{identifier, character}

View file

@ -25,6 +25,7 @@ Can be used as a substitute of the base function. Main claim to fame is
easing the split around the defined delimiter, see example.
}
\examples{
test <- c("12 months follow-up", "3 steps", "mRS 6 weeks", "Counting to 231 now")
test <- c("12 months follow-up", "3 steps", "mRS 6 weeks",
"Counting to 231 now")
strsplitx(test, "[0-9]", type = "around")
}

View file

@ -2,8 +2,7 @@
% Please edit documentation in R/ds2dd_detailed.R
\name{time_only_correction}
\alias{time_only_correction}
\title{Correction based on time_only_filter function. Introduces new class for easier
validation labelling.}
\title{Correction based on time_only_filter function}
\usage{
time_only_correction(data, ...)
}
@ -16,8 +15,7 @@ time_only_correction(data, ...)
tibble
}
\description{
Dependens on the data class "hms" introduced with
`guess_time_only_filter()` and converts these
Correction based on time_only_filter function
}
\examples{
data <- redcapcast_data