Skip to content

Commit

Permalink
Merge pull request #34 from gongcastro/test
Browse files Browse the repository at this point in the history
v1.0.1
  • Loading branch information
gongcastro authored Oct 22, 2023
2 parents d3312bc + f48e08d commit ecb41e1
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 32 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ importFrom(rlang,enquos)
importFrom(tibble,tibble)
importFrom(tidyr,pivot_longer)
importFrom(tidyr,pivot_wider)
importFrom(utils,browseURL)
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions R/globals.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ utils::globalVariables(unique(c(
"response",
"study",
"time_stamp",
"browseURL",
# bvq_participants:
"code",
"date_birth",
Expand Down
5 changes: 3 additions & 2 deletions R/responses.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) %>%
Expand Down
15 changes: 15 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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


1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ reference:
contents:
- get_longitudinal
- prop_adj
- launch_app
- title: "Internals"
desc: "Helper functions used internally"
contents:
Expand Down
55 changes: 25 additions & 30 deletions data-raw/pool.R
Original file line number Diff line number Diff line change
@@ -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)
Binary file modified data/pool.rda
Binary file not shown.
Binary file modified inst/extdata/pool.xlsx
Binary file not shown.
Binary file modified inst/fixtures/pool.rds
Binary file not shown.
Binary file modified inst/formr/bvq-v1.0.0/bvq_06_words_catalan.xlsx
Binary file not shown.
17 changes: 17 additions & 0 deletions man/launch_app.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ecb41e1

Please sign in to comment.