Git Product home page Git Product logo

ggcheck's Introduction

ggcheck

CRAN status R-CMD-check

ggcheck provides functions that inspect ggplot2 objects to make it easier for teachers to check that student plots meet expectations. Designed primarily for automated grading via gradethis in interactive learnr tutorials.

Installation

You can install ggcheck from GitHub with:

# install.packages("remotes")
remotes::install_github("rstudio/ggcheck")

Usage

The primary goal of ggcheck is to help tutorial authors inspect and test properties of ggplot2 plots. The examples below demonstrate how ggcheck can be used in general; for more information about using gradethis in learnr tutorials, please see the gradethis package documentation.

Suppose an exercise asks students to create the following plot of engine displacement vs highway miles per gallon ratings.

library(ggplot2)

p <-
  ggplot(data = mpg, mapping = aes(x = displ, y = hwy)) +
  geom_point(mapping = aes(color = class)) +
  geom_smooth(se = FALSE, method = "lm")

p
#> `geom_smooth()` using formula = 'y ~ x'

We can use ggcheck to test that students used geom_point()

library(ggcheck)

uses_geoms(p, "point", exact = FALSE)
#> [1] TRUE

or that both geom_point() and geom_smooth() were used

uses_geoms(p, c("point", "smooth"), exact = FALSE)
#> [1] TRUE

or that exactly both geom_point() and geom_smooth() were used and in that order.

uses_geoms(p, c("point", "smooth"), exact = TRUE)
#> [1] TRUE

Similarly, we can test that a linear model was used for the smoothing method and the confidence interval was not displayed:

uses_geom_param(p, "smooth", list(se = FALSE, method = "lm"))
#>     se method 
#>   TRUE   TRUE

There’s a lot more that ggcheck can do. Read more in the full function listing.

Code of Conduct

Please note that the tblcheck project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.