Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Commit

Permalink
enable english full items in plots as per #30
Browse files Browse the repository at this point in the history
  • Loading branch information
maxheld83 committed Apr 15, 2019
1 parent 76c024a commit 214a621
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ plot_battery <- function(m, items = NULL, condition = "expect_crowd", lang = "en
items <- colnames(m)
}

# make good item labels on y axis
quest %>%
dplyr::filter(section == condition) %>%
dplyr::filter(var %in% items) %>%
dplyr::mutate(var_german = stringr::str_wrap(string = var_german, width = width)) %>%
dplyr::mutate(var_english = stringr::str_wrap(string = var_english, width = width)) %>%
{.} -> df
if (lang == "de") {
quest %>%
dplyr::filter(section == condition) %>%
dplyr::filter(var %in% items) %>%
dplyr::mutate(var_german = stringr::str_wrap(string = var_german, width = width)) %>%
{.} -> df
long <- glue::glue_data(
.x = df,
"...{var_german}",
Expand All @@ -18,10 +20,15 @@ plot_battery <- function(m, items = NULL, condition = "expect_crowd", lang = "en
)
long <- rlang::set_names(x = long, nm = df$var)
} else {
long <- colnames(m)
long <- glue::glue_data(
.x = df,
"...{var_english}",
"({var})",
.sep = "\n"
)
long <- rlang::set_names(x = long, nm = df$var)
}


# munge data
m[, items] %>%
as_tibble() %>%
Expand Down

0 comments on commit 214a621

Please sign in to comment.