Skip to content

Commit

Permalink
Fix summarise by prof functions (#77)
Browse files Browse the repository at this point in the history
* Remove NA rows

* Fix pushed error in last commit

* Add sample sizes for each profession
  • Loading branch information
ldavies99 authored Jan 11, 2024
1 parent af886a1 commit 9b9e6e1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions R/frequency-tables.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
)
)
}

Expand Down Expand Up @@ -996,7 +1005,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) {

Expand Down Expand Up @@ -1050,7 +1059,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) {

Expand Down
2 changes: 1 addition & 1 deletion quarto/main/summary.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Please note that respondents might be members of more than one profession.
```{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)
```


Expand Down

0 comments on commit 9b9e6e1

Please sign in to comment.