Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add data processing functions for grammar questionnaire #61

Merged
merged 5 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .Rprofile
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,11 @@ if (interactive()) {
cli::cli_alert_info(R.version$version.string)
cli::cli_text("")

# customise the prompt
prompt::set_prompt(function(...) {
branch <- suppressWarnings(purrr::safely(gert::git_branch)())
if (is.null(branch$result)) {
return("> ")
}
return(paste0("[", branch$result, "] > "))
})


# usethis options
options(usethis.protocol = "ssh")
options(usethis.full_name = "gongcastro")

# bias against scientific notation
options(scipen = 4)

# print loaded packages
cli::cli_alert_success(
paste0(
"Loaded: ",
paste0(
sessioninfo::session_info()$packages[sessioninfo::session_info()$packages$attached, 1],
collapse = ", "
)
)
)
cli::cli_text("")

load_all()
}
6 changes: 3 additions & 3 deletions R/connect.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ bvq_connect <- function(google_email = NULL,
if (is.null(password)) {
password <- Sys.getenv("FORMR_PWD", unset = NA)
if (is.na(password)) {
cli_abort("Please, provide a password")
cli::cli_abort("Please, provide a password")
}
}

# if key exists, use it to log in
tryCatch(
suppressWarnings(
formr::formr_connect(keyring = "formr")
formr::formr_connect(email = formr_email, keyring = "formr")
),
error = function(e) {
cli_abort(
Expand All @@ -56,7 +56,7 @@ bvq_connect <- function(google_email = NULL,
)

# check if Google credentials exists, ask for them if not
if (!gs4_has_token()) {
if (!googlesheets4::gs4_has_token()) {
tryCatch(
suppressWarnings({
googlesheets4::gs4_auth(
Expand Down
8 changes: 4 additions & 4 deletions R/import.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @importFrom cli cli_alert_success
#'
#' @param version Character string indicating the name fo the formr run (must be one of "lockdown", "long", or "short")
#' @param version Character string indicating the name fo the formr run (must be one of "bvq-1.0.1", "bvq-1.0.0", "bvq-lockdown", "bvq-long", or "bvq-short")
#' @param participants Participants dataset, as returned by [bvq::bvq_participants()]
#' @param ... Unused.
#'
Expand All @@ -19,7 +19,7 @@ collect_survey <- function(version,
# validate version name
survey_options <- names(get_bvq_runs())
if (!(version %in% survey_options)) {
cli_abort("survey must be one of {survey_options}")
cli::cli_abort("survey must be one of {survey_options}")
}

# correct version names
Expand Down Expand Up @@ -47,7 +47,7 @@ collect_survey <- function(version,
if (interactive()) {
n_responses <- nrow(distinct(processed, response_id))
msg <- "{version} updated: {n_responses} response{?s} retrieved"
cli_alert_success(msg)
cli::cli_alert_success(msg)
}

return(processed)
Expand Down Expand Up @@ -78,7 +78,7 @@ download_surveys <- function(surveys, verbose = TRUE, ...) {

if (verbose && interactive()) {
step_msg <- "Downloaded {i}/{n} {qty(i)}survey{?s}"
cli_progress_step(msg = step_msg)
cli::cli_progress_step(msg = step_msg)
}

for (i in seq_along(surveys)) {
Expand Down
4 changes: 2 additions & 2 deletions R/participants.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ bvq_participants <- function(...) {
sheet <- read_sheet(
ss = "164DMKLRO0Xju0gdfkCS3evAq9ihTgEgFiuJopmqt7mo",
sheet = "Participants",
col_types = "cccciDnccccDDclcc",
col_types = "cccciDnccccDDcllcc",
.name_repair = janitor::make_clean_names
)
})
Expand All @@ -74,7 +74,7 @@ bvq_participants <- function(...) {
) %>%
mutate(
response_id = gsub("BL", "", response_id),
version = gsub("bl-", "", tolower(version))
version = gsub("bl-|bvq-", "", tolower(version))
) %>%
# reorder rows
arrange(desc(as.numeric(response_id)))
Expand Down
3 changes: 2 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ get_bvq_runs <- function() { # nocov start
"bvq_04_demo",
"bvq_05_language",
"bvq_06_words_catalan",
"bvq_06_words_spanish"
"bvq_06_words_spanish",
"bvq_grammar"
),
"bvq-lockdown" = c(
"bilexicon_lockdown_01_log",
Expand Down
Loading