From 0930a943fa4ff72d4e6528b8928ad08e64846e02 Mon Sep 17 00:00:00 2001 From: daviel9 Date: Mon, 8 Jan 2024 16:41:07 +0000 Subject: [PATCH 1/3] Remove NA rows --- R/frequency-tables.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/frequency-tables.R b/R/frequency-tables.R index 1a03c12..531aec7 100644 --- a/R/frequency-tables.R +++ b/R/frequency-tables.R @@ -996,7 +996,7 @@ summarise_languages_by_prof <- function(data) { names(prof_names) <- profs outputs <- lapply(profs, function(prof) { - filtered_data <- data[data[prof] == "Yes", ] + filtered_data <- dplyr::filter(data, get(prof) == "Yes") if(nrow(filtered_data) > 0) { @@ -1050,7 +1050,7 @@ summarise_open_source_by_prof <- function(data) { names(prof_names) <- profs outputs <- lapply(profs, function(prof) { - filtered_data <- data[data[prof] == "Yes", ] + filtered_data <- dplyr::filter(data, get(prof) == "Yes") if(nrow(filtered_data) > 0) { @@ -1153,7 +1153,7 @@ summarise_os_vs_prop <- function(data) { data.frame %>% get_ci(freq_col = 2, n_col = 3) - os_freqs <- cbind(lang_type = "Open Source", os_freqs) + os_freqs <- cbind(lang_type = "open Source", os_freqs) prop_freqs <- data %>% dplyr::group_by(year) %>% From f8f2a1d8482fe39a735b05fd08820e506bc8e7bb Mon Sep 17 00:00:00 2001 From: daviel9 Date: Wed, 10 Jan 2024 12:53:34 +0000 Subject: [PATCH 2/3] Fix pushed error in last commit --- R/frequency-tables.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/frequency-tables.R b/R/frequency-tables.R index 531aec7..c0e748d 100644 --- a/R/frequency-tables.R +++ b/R/frequency-tables.R @@ -1153,7 +1153,7 @@ summarise_os_vs_prop <- function(data) { data.frame %>% get_ci(freq_col = 2, n_col = 3) - os_freqs <- cbind(lang_type = "open Source", os_freqs) + os_freqs <- cbind(lang_type = "Open Source", os_freqs) prop_freqs <- data %>% dplyr::group_by(year) %>% From b75a52c9ac08deef5cbb9ab377d516f2ab788ef4 Mon Sep 17 00:00:00 2001 From: daviel9 Date: Wed, 10 Jan 2024 16:09:50 +0000 Subject: [PATCH 3/3] Add sample sizes for each profession --- R/frequency-tables.R | 11 ++++++++++- quarto/main/summary.qmd | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/R/frequency-tables.R b/R/frequency-tables.R index c0e748d..a2cbe61 100644 --- a/R/frequency-tables.R +++ b/R/frequency-tables.R @@ -70,7 +70,16 @@ sample_sizes <- function(data) { code_at_work = sum(!is.na(data$code_freq) & data$code_freq != "Never"), other_code_experience = sum(!is.na(data$other_coding_experience ) & data$other_coding_experience == "Yes"), heard_of_RAP = sum(!is.na(data$heard_of_RAP) & data$heard_of_RAP == "Yes"), - not_RAP_champ = sum(is.na(data$know_RAP_champ) | data$know_RAP_champ != "I am a RAP champion") + not_RAP_champ = sum(is.na(data$know_RAP_champ) | data$know_RAP_champ != "I am a RAP champion"), + + profs = sapply(c("prof_DE", "prof_DS", "prof_DDAT", "prof_GAD", "prof_GES", + "prof_geog", "prof_GORS", "prof_GSR", "prof_GSG"), + function(prof) { + prof_sample <- paste0(sum(data[prof] == "Yes", na.rm = TRUE), " (", substring(prof, 6), ")") + + return(prof_sample) + } + ) ) } diff --git a/quarto/main/summary.qmd b/quarto/main/summary.qmd index 2be7cf3..13e9302 100644 --- a/quarto/main/summary.qmd +++ b/quarto/main/summary.qmd @@ -149,7 +149,7 @@ However, proprietary tools tend to be more profession-specific. For example, eco ```{R} colnames(tables$languages_by_prof)[2] <- "Profession" -tables$languages_by_prof[c(2,1,3)] %>% CARS::df_to_table(crosstab = T, proportion_col = 3) +tables$languages_by_prof[c(2,1,3)] %>% CARS::df_to_table(n = samples$profs, crosstab = T, proportion_col = 3) ```