Jazmine T.

asked • 12/07/20

If 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

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.