categorize_job <- function(description) {
if (grepl("communication|inform|listen", description, ignore.case = TRUE)) {
return("Communication : honest information dissemination")
} else if (grepl("safety|health|protect", description, ignore.case = TRUE)) {
return("Public Safety and Health: public protection")
} else if (grepl("policy|leadership|govern", description, ignore.case = TRUE)) {
return("Leadership and Governance: policy, implementation, decision-making")
} else if (grepl("resource|budget|manage", description, ignore.case = TRUE)) {
return("Resource Management: infrastructure, resource allocation")
} else if (grepl("hope|resilience|morale", description, ignore.case = TRUE)) {
return("Emotional and Psychological Well-being: hope, resilience, public morale")
} else {
return("Uncategorized")
}
}
my_data <- my_data %>%
mutate(Category = sapply(`What do you think is the single most important part of your job as a public official?`, categorize_job))
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter