diff --git a/NAMESPACE b/NAMESPACE index d2bc6e9..039bdbe 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -55,3 +55,4 @@ importFrom(rlang,enquos) importFrom(tibble,tibble) importFrom(tidyr,pivot_longer) importFrom(tidyr,pivot_wider) +importFrom(utils,browseURL) diff --git a/NEWS.md b/NEWS.md index d15b612..f43b21d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,10 @@ +# bvq 1.0.1 + +- New function `launch_app()` that opens the BVQ app (see [https://github.com/gongcastro/bvq-app](https://github.com/gongcastro/bvq-app)) on a browser +- Fixed `n_lemma` score for item `cat_gos` in `pool` (#33) +- Add item `cat_vaixell` to Catalan checklist, which was missing (#32) +- Some minor refactoring for readability + # bvq 1.0.0 ## formr implementation diff --git a/R/globals.R b/R/globals.R index 1f62095..8e5b2f4 100644 --- a/R/globals.R +++ b/R/globals.R @@ -11,6 +11,7 @@ utils::globalVariables(unique(c( "response", "study", "time_stamp", + "browseURL", # bvq_participants: "code", "date_birth", diff --git a/R/responses.R b/R/responses.R index 631264c..deecaff 100644 --- a/R/responses.R +++ b/R/responses.R @@ -45,8 +45,9 @@ #' @md bvq_responses <- function(participants = bvq_participants()) { - responses <- map(names(get_bvq_runs()), - function(x) collect_survey(x, participants)) %>% + responses <- get_bvq_runs() %>% + names() %>% + map(function(x) collect_survey(x, participants)) %>% bind_rows() %>% # remove duplicated combinations distinct(child_id, response_id, item, .keep_all = TRUE) %>% diff --git a/R/utils.R b/R/utils.R index fdd453f..7d33322 100644 --- a/R/utils.R +++ b/R/utils.R @@ -357,3 +357,18 @@ prop_adj <- function(x, n) { (x + 2) / (n + 4) } +#' Launch bvq Shiny App in a browser +#' +#' @source https://github.com/gongcastro/bvq-app +#' +#' @importFrom utils browseURL +#' +#' @details The BVQ Shiny App provides a visual interface to the bvq R package to explore the database. Its [GitHub repository](https://github.com/gongcastro/bvq-app) contains the data, documentation, and R scripts needed to run the BVQ Shiny app. +#' +launch_app <- function() { # nocov start + browseURL("https://gongcastro.shinyapps.io/bvq-app/", + browser = getOption("browser"), + encodeIfNeeded = FALSE) +} # nocov end + + diff --git a/_pkgdown.yml b/_pkgdown.yml index 701ecbc..f56c812 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -53,6 +53,7 @@ reference: contents: - get_longitudinal - prop_adj + - launch_app - title: "Internals" desc: "Helper functions used internally" contents: diff --git a/data-raw/pool.R b/data-raw/pool.R index 4e75474..47642c3 100644 --- a/data-raw/pool.R +++ b/data-raw/pool.R @@ -1,42 +1,37 @@ ## code to prepare `pool` dataset goes here library(dplyr) +library(tidyr) +library(ipa) library(readxl) # uni lemmas -worbank_lemmas <- read.delim( - system.file("extdata/lemmas.txt", - package = "bvq" - ), - sep = "\t", - quote = "" -) %>% - select(te, item, ends_with("lemma")) +worbank_lemmas <- read.delim(system.file(file.path("extdata", "lemmas.txt"), + package = "bvq"), + sep = "\t", + quote = "") %>% + select(te, item, ends_with("lemma")) # import pool -pool <- read_xlsx("inst/extdata/pool.xlsx") %>% - left_join(worbank_lemmas, - by = join_by(item, te) - ) %>% - mutate( - language = ifelse(grepl("cat_", item), - "Catalan", - "Spanish" - ), - xsampa = ipa(ipa, "xsampa") - ) %>% - select( - item, language, te, label, xsampa, - n_lemmas, is_multiword, subtlex_lemma, wordbank_lemma, - childes_lemma, semantic_category, class, version, include - ) %>% - drop_na(version) %>% - mutate(across(c(te, n_lemmas), as.integer), - across(c(is_multiword, include), as.logical), - version = strsplit(version, split = ",") - ) +pool <- system.file(file.path("extdata", "pool.xlsx"), + package = "bvq") %>% + read_xlsx() %>% + left_join(worbank_lemmas, + by = join_by(item, te)) %>% + mutate(language = ifelse(grepl("cat_", item), + "Catalan", + "Spanish"), + xsampa = ipa(ipa, "xsampa")) %>% + select(item, language, te, label, xsampa, + n_lemmas, is_multiword, subtlex_lemma, wordbank_lemma, + childes_lemma, semantic_category, class, version, include) %>% + drop_na(version) %>% + mutate(across(c(te, n_lemmas), as.integer), + across(c(is_multiword, include), as.logical), + version = strsplit(version, split = ",")) # export for future testing -saveRDS(pool, test_path("fixtures", "pool.rds")) +saveRDS(pool, system.file(file.path("fixtures", "pool.rds"), + package = "bvq")) # export pool database usethis::use_data(pool, overwrite = TRUE, internal = FALSE) diff --git a/data/pool.rda b/data/pool.rda index 3280114..cbb5b39 100644 Binary files a/data/pool.rda and b/data/pool.rda differ diff --git a/inst/extdata/pool.xlsx b/inst/extdata/pool.xlsx index 0ace9a0..9252c48 100644 Binary files a/inst/extdata/pool.xlsx and b/inst/extdata/pool.xlsx differ diff --git a/inst/fixtures/pool.rds b/inst/fixtures/pool.rds index bb99ddb..a8f4e1f 100644 Binary files a/inst/fixtures/pool.rds and b/inst/fixtures/pool.rds differ diff --git a/inst/formr/bvq-v1.0.0/bvq_06_words_catalan.xlsx b/inst/formr/bvq-v1.0.0/bvq_06_words_catalan.xlsx index 84de41e..4afb8a0 100644 Binary files a/inst/formr/bvq-v1.0.0/bvq_06_words_catalan.xlsx and b/inst/formr/bvq-v1.0.0/bvq_06_words_catalan.xlsx differ diff --git a/man/launch_app.Rd b/man/launch_app.Rd new file mode 100644 index 0000000..6e2da39 --- /dev/null +++ b/man/launch_app.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils.R +\name{launch_app} +\alias{launch_app} +\title{Launch bvq Shiny App in a browser} +\source{ +https://github.com/gongcastro/bvq-app +} +\usage{ +launch_app() +} +\description{ +Launch bvq Shiny App in a browser +} +\details{ +The BVQ Shiny App provides a visual interface to the bvq R package to explore the database. Its \href{https://github.com/gongcastro/bvq-app}{GitHub repository} contains the data, documentation, and R scripts needed to run the BVQ Shiny app. +}