sd should be part of the same summarize function as the mean.
Jazmine T.
asked 12/07/20If I am trying to create a barplot with errors, what am I doing wrong in this code that is producing an error?
Error message:
Error: unexpected '=' in:
" summarise(`Support For H-1B Visas` = mean(h1bvis.supp, na.rm = TRUE) %>%
sd ="
Code:
immig %>%
mutate(`Full Sample` = case_when(
tech.whitcol==1~ "Tech Workers",
nontech.whitcol==1~ "Other White Collar Workers",
nontech.whitcol==0 & employed==1~ "Non-Tech/Non-White Collar Workers",
employed==0~ "Not Employed" )) %>%
group_by(`Full Sample`) %>%
summarise(`Support For H-1B Visas` = mean(h1bvis.supp, na.rm = TRUE) %>%
sd = sd(`Full Sample`[[col]], na.rm=TRUE)) %>%
ggplot(aes(`Full Sample`,`Support For H-1B Visas`)) +
geom_bar(stat="identity") +
geom_errorbar(aes(ymin=`Support for H-1B Visas` - sd, ymax=`Support for H-1B Visas` - sd), width=.2) +
ggtitle("(a) Economic threat reduces support for H-1B visas")
2 Answers By Expert Tutors
Inactive Tutor answered 02/08/21
Rewrite the following chunk as:
summarise(`Support For H-1B Visas` = mean(h1bvis.supp, na.rm = TRUE),
sd = sd(`Full Sample`[[col]], na.rm=TRUE)) %>%
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.