Skip to content

Instantly share code, notes, and snippets.

@yvlau92
Created February 13, 2017 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yvlau92/5e550eb6b83441dc3d8bd0e0c5aa6a33 to your computer and use it in GitHub Desktop.
Save yvlau92/5e550eb6b83441dc3d8bd0e0c5aa6a33 to your computer and use it in GitHub Desktop.
Distribution of restaurant grades
# Shiny Server Code to render distribution of grades plot
output$grade_plot <- renderGvis({
# transform data for GoogleVis: group by year and grade
grade_only_grouped <- grade_data()%>%
group_by(year,grade)%>%
summarise(n=n())
#melt and cast data into the format for stacked googlevis
mgrade_only <- melt(grade_only_grouped, id = c("grade","year"))
grade_dist <- cast(mgrade_only, year~grade,sum)
gvisColumnChart(grade_dist, options = list(
isStacked="percent", colors="['#A6D0BD','#565656','red']"))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment