Skip to content

Commit

Permalink
diabetesprevalence data #10
Browse files Browse the repository at this point in the history
  • Loading branch information
SchmidtPaul committed Mar 17, 2021
1 parent 59c7306 commit 4eb7950
Show file tree
Hide file tree
Showing 11 changed files with 249 additions and 28 deletions.
1 change: 0 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
^\.travis.yml
^\_pkgdown.yml
^LICENSE
^data/.
^vignettes/.
^logo.png
^BioMathlogo.svg
Expand Down
8 changes: 8 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#' 5002 publications on diabetes prevalence
#'
#' A dataset containing 5002 publications exported from a Citavi project.
#'
#' @format A data frame with 5002 rows and 25 variables.
#' @usage data(diabetesprevalence)
"diabetesprevalence"

25 changes: 19 additions & 6 deletions R/detect_language.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
#'
#' @details
#' `r lifecycle::badge("experimental")` \cr
#' Currently this only works for files that were generated while Citavi
#' was set to "English" so that column names are "Short Title" etc.
#' The underyling core function determining the language is \code{textcat::textcat()}.
#'
#' @examples
#' path <- example_xlsx("3dupsin5refs.xlsx")
#' read_Citavi_xlsx(path) %>%
#' detect_language() %>%
#' dplyr::select(Title, Abstract, det_lang, det_lang_wanted)
#' CitDat <- CitaviR::diabetesprevalence %>%
#' dplyr::slice(1952:1955, 4390:4393)
#'
#' CitDat %>%
#' detect_language() %>%
#' dplyr::select(Abstract, det_lang, det_lang_wanted)
#'
#' @return A tibble containing at least one additional column: \code{det_lang}.
#' @importFrom textcat textcat
Expand All @@ -29,6 +30,18 @@
#'
detect_language <- function (CitDat, fieldsToDetectIn = c("Abstract"), wantedLanguage = c("english")) {

# stop if empty arguments -------------------------------------------
if (is.null(all_of(fieldsToDetectIn))) {
stop("'fieldsToDetectIn' must not be NULL/NA.")
}


# check if fieldsToDetectIn are present -----------------------------------
if (!all_of(fieldsToDetectIn %in% names(CitDat))) {
stop(paste("Could not be found in dataset column names:\n",
fieldsToDetectIn[fieldsToDetectIn %not_in% names(CitDat)]))
}


# collapse fieldsToDetectIn -----------------------------------------------
CitDat <- CitDat %>%
Expand Down
3 changes: 2 additions & 1 deletion _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ reference:
- read_Citavi_xlsx
- write_Citavi_xlsx

- title: Utility
- title: Utility & Data
contents:
- '`%not_in%`'
- example_xlsx
- diabetesprevalence
12 changes: 12 additions & 0 deletions data-raw/diabetesprevalence.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
suppressWarnings(
diabetesprevalence <-
CitaviR::read_Citavi_xlsx(
path = "data-raw/diabetesprevalence.xlsx",
keepMarksCols = TRUE,
useYearDerived = TRUE,
setSuggestedColOrder = TRUE,
setSuggestedColTypes = TRUE
)
)

usethis::use_data(diabetesprevalence, overwrite = TRUE, internal = FALSE)
Binary file added data-raw/diabetesprevalence.xlsx
Binary file not shown.
Binary file added data/diabetesprevalence.rda
Binary file not shown.
32 changes: 18 additions & 14 deletions docs/reference/detect_language.html

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

167 changes: 167 additions & 0 deletions docs/reference/diabetesprevalence.html

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

13 changes: 7 additions & 6 deletions man/detect_language.Rd

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

16 changes: 16 additions & 0 deletions man/diabetesprevalence.Rd

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

0 comments on commit 4eb7950

Please sign in to comment.