Skip to content

Instantly share code, notes, and snippets.

@naomispence
Created November 30, 2016 17:42
Show Gist options
  • Save naomispence/75410ea83cdcb8827d543434ec4cc5ba to your computer and use it in GitHub Desktop.
Save naomispence/75410ea83cdcb8827d543434ec4cc5ba to your computer and use it in GitHub Desktop.
#create new temporary dataset that filters out the missing (NA) values so that they don't appear in the graph
polviewsnew<-dplyr::filter(GSS2014, polviews!='NA')
#create a bar graph using the new temporary dataset
ggplot(polviewsnew, aes(x=polviews)) +
geom_bar(stat ="count", color="red", fill="white", aes(y = ((..count..)/sum(..count..)))) +
ggtitle("Political Views") +
labs(y="Percent", x="Political Views") + scale_y_continuous(labels=percent)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment