/ Research / Gradebook analysis with R – Part III

Gradebook analysis with R – Part III

Assorted Electronics on table
Share on facebook
Share on linkedin
Share on twitter
Share on pinterest

This is Part III in Scout from University of California’s three-part series, Gradebook analysis with R. If you missed Part I or Part II, click here for Part I and here for Part II

OR logo

In Parts I and II we showed how to clean, tidy, explore and plot your gradebook data. Now it’s time to show off some of that work and turn your findings into shareable data products. Data analysis is, after all, a communal activity, and there’s no sense in hogging all that insight to yourself. Sharing is caring.

Towards that end, we’ll explain how to share your data in a variety of ways and formats. If there’s a single takeaway from this post, it’s that there are tools and resources in R to create almost any presentation imaginable.

Sharing Image Files

In the event that you do find a plot worth sharing, you can save any ggplot2 plot to an image file with the ggsave() function. The file will be saved to your current working directory.

#After creating a ggplot object:
ggsave(file = “final_exam_histogram.png”)

#Or, create a ggplot object and pass it to ggsave():
plot1 <- ggplot(plot_data, aes(Final)) + geom_histogram()
ggsave(“final_exam_histogram.png”, plot1)

And if you’re creating plots in base R, you can also use the respective png(), jpg(), or pdf() functions. Alternatively, if you’re working in the integrated development environment (IDE–software applications that provide a variety of tools for programmers) RStudio , you can also just export the plot to an image file from within the interface. This is handy not only because it saves you from writing additional code, but because you can resize the image to any desired specifications while maintaining its aspect ratio:

Save plot as image graph

Sharing CSV or Spreadsheet Files

A colleague may also request a spreadsheet of your tidied data, and you can create a CSV or Excel Workbook with write.csv() or write.xlsx() from the xlsx package. Again, the file will be saved to your current working directory.

write.csv(apcalcbc, file = “apcalcbc.csv”) #The first argument is the name of the R object

write.xlsx(apcalcbc, file = “apcalcbc.xlsx”, sheetName = “AP Calculus BC”)

If you’re working with data from Google Sheets, we highly recommend the googlesheets() package which allows you to access, extract, edit, create, delete or copy data from your Google Drive. The documentation on GitHub is fantastic and gets you up and running in no time.

Sharing With R Markdown and RPubs

Authoring scripts in R Markdown allow you to create dynamic documents, presentations and reports. If you’re familiar with markdown syntax, picking up R Markdown will be a cinch. But even if you’ve never written a line of markdown, the conventions are easy to follow with a cheat sheet nearby. Along with its reproducibility, one of the main advantages of R Markdown scripts is how neatly and orderly it renders plots, blocks of code, tables and images. This entire series, for example, was authored in R Markdown and “knit” to HTML files with the knitr package. In the image below, the left pane shows my R Markdown script from Part II, and the right pane shows some of the rendered HTML output.

Knit image

With a little twist, you can also create HTML5 slides with R Presentations within RStudio:

Create slides image

Finally, you can publish all of your R Markdown documents to RPubs, a free web publishing site if you so desire. All you need is an account.

Sharing Shiny Apps

Disclaimer: Shiny apps are relatively easy to create, but require a measure of patience, forethought and attention to detail. In brief, Shiny allows you to create interactive web applications with zero knowledge of HTML, CSS or JavaScript. The possibilities are endless, but you would be wise to visit with whomever you intend to showcase your data in advance. What precisely do they need to see? In the context of student performance and gradebooks, what data stimulates substantive discussion, or stirs imaginative thinking? Is the purpose to showcase student performance or evaluate the curriculum? Without clear direction, Shiny app development tends to wander.

The available Shiny documentation is superb, and we highly recommend working through RStudio’s Shiny tutorials. Their gallery of Shiny apps is also a fountain of inspiration.

In the example below, we created a Shiny app that integrates data from our LMS, SIS and course evaluations. The app responds to user input: it will rerun when a different course is selected, or when the number of histogram bins is adjusted. The user can check the overall grade distribution on the “Grade Distribution” tab, view student performance by gender on the “Performance by Gender” tab, and isolate test performance on the “Test Performance” tab. The bar plots on the bottom show student responses to the course evaluation. Thus, with just a few clicks, users can get a sense of both student performance and student appreciation.

Screenshot of the Shiny App:

Screenshot of shiny app

Here is the code for this particular app (Note: evaluations and gradebooks are objects in my environment):


ui <- fluidPage(
titlePanel(“Scout Gradebook Data”),
selectInput(“course”, “Select Course:”, choices = c(“Geometry”, “AP Calculus BC”), selected = “Geometry”),
sliderInput(“slider”, “Bins:”, min = 5, max = 15, value = 8, step = 1)
column(width = 9,
tabPanel(“Grade Distribution”, plotOutput(“histogram”)),
tabPanel(“Performance by Gender”, plotOutput(“violins”)),
tabPanel(“Test Performance”, dataTableOutput(“tests”))
fluidRow(h3(“Course Evaluation Responses”),
column(width = 9,

server <- function(input, output) {

gradebook <- reactive({
gradebooks %>%
filter(Course == input$course)

output$histogram <- renderPlot({

ggplot(gradebook(), aes(Grade)) +
geom_histogram(bins = input$slider, fill = “lightblue”, color = “black”) +

output$violins <- renderPlot({

plot_data <- gradebook() %>%

ggplot(plot_data, aes(Gender, Final, fill = Gender)) +

output$tests <- renderDataTable({

gradebook() %>%
distinct(Student) %>%
select(Student, Grade, Final, Result) %>%

output$evaluations <- renderPlot({

eval_plot_data <- evaluations %>%
filter(Course == input$course)

ggplot(evaluations, aes(Response, Counts)) +
geom_bar(stat = “identity”, fill = “orange”) +
facet_grid(~Question) +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1))

shinyApp(ui = ui, server = server)

You can further customize the look and feel with the shinythemes package, or create more robust dashboards with the shinydashboard package. There are hundreds of features to explore, from collapsing boxes to reactive user interfaces. Finally, you can publish your app to the web through shinyapps.io. There is a free version, but it comes with limitations to run time and security unless you upgrade to a paid subscription.

R Resources

If you made it this far, you’re probably interested in learning more about R and perhaps teaching yourself. The internet is full of helpful courses, videos and blogs, but here are some I found/find particularly useful:


University of California-Scout logo

About the Author

David Ranzolin wrangles, slices, and dices data for Scout, but he also likes to pal around with the English department reciting Julius Caesar, extolling the innumerable merits of East of Eden, and arguing about the hegemonic canon.

About Scout

Learning is synonymous with empowerment at Scout. We are teachers, instructional designers and technologists working to deliver University of California-quality interactive online classes, curriculum and supplemental education materials to middle school and high school students and teachers across the U.S. and beyond. Our course materials are designed to inspire life-long curiosity and prepare pupils of all backgrounds and education levels for an increasingly technological world where training and job skills are mobile, asynchronous and self-directed. Explicitly created to bridge achievement gaps, we believe that using technology effectively can remove traditional obstacles to education.

Share on facebook
Share on linkedin
Share on twitter
Share on pinterest
Michigan Virtual Learning Research Institute

Michigan Virtual Learning Research Institute

The Michigan Virtual Learning Research Institute (MVLRI) is a non-biased organization that exists to expand Michigan’s ability to support new learning models, engage in active research to inform new policies in online and blended learning, and strengthen the state’s infrastructures for sharing best practices. MVLRI works with all online learning environments to develop the best practices for the industry as a whole.

Keep up with the latest Michigan Virtual has to offer

The Digital Backpack

Get our latest articles sent straight to your inbox every Thursday!

  • This field is for validation purposes and should be left unchanged.

Limited Course Capacity

We’re sorry to inform you that we have reached capacity for several of our Semester 1 and Trimester 1 courses. You’ll notice when attempting to enroll students in our Student Learning Portal that some courses are unavailable. While we are no longer accepting new enrollments for these courses at this time, many courses continue to remain open for enrollment.

With many students across the state 100% remote, demand for our online courses is greater than ever before. Because every course we offer is taught by a Michigan-certified teacher, this high volume of enrollments has created capacity issues for our teachers who provide each and every student with individual feedback.

While the Michigan Virtual team anticipated and planned for significant increases in student enrollments this Fall, the increased demand we’ve experienced has been unprecedented. As a result, we are taking steps to hire even more part-and full-time teachers to support larger numbers of student enrollments for Semester 2 as well as for Trimester 2 and 3. 

For schools that still need online learning options this year, please fill out the form at the bottom of our virtual pathways page to meet with someone to discuss other solutions. While some of our teacher-led courses are full, we may still have the capacity to help you in upcoming terms or can discuss timing to implement a whole-school or collaborative program in which local teachers from your school/district use our online course content to teach students. We also have free course content and resources available for you to use.

We know this is an incredibly stressful time for all, and we’re sorry if the courses you’re looking for are unavailable. We never want to turn away a student who wants to learn from us. Our top concern, however, is student success, and we have a policy to not take on additional enrollments if we cannot guarantee that all students will have a quality online learning experience. 

We appreciate your patience and understanding as we navigate the unusually high volume of enrollments we are receiving.