## ----setup, include=FALSE-----------------------------------------------------
knitr::opts_chunk$set(message = FALSE, warning = FALSE)

## ----quickstart-basic---------------------------------------------------------
library(ggplot2)
library(GoldenVizR)

p <- ggplot(mtcars, aes(wt, mpg, colour = factor(cyl))) +
  geom_point() +
  labs(
    title = "Fuel economy by weight",
    subtitle = "Motor Trend cars",
    x = "Weight",
    y = "Miles per gallon",
    colour = "Cylinders",
    caption = "Source: mtcars"
  )

report <- analyze_plot(p)
report$summary

## ----quickstart-attention-----------------------------------------------------
subset(report$rule_results, status != "PASS")

## ----quickstart-manual-one-plot-----------------------------------------------
manual_plot <- ggplot(mtcars, aes(factor(cyl), mpg)) +
  geom_boxplot() +
  labs(
    title = "Fuel economy by cylinder count",
    x = "Cylinders",
    y = "Miles per gallon",
    caption = "Source: mtcars"
  )

manual_report <- analyze_plot(manual_plot)
manual_report$summary

## ----quickstart-manual-rules--------------------------------------------------
manual_report$rule_results

## ----quickstart-manual-issues-------------------------------------------------
subset(manual_report$rule_results, status != "PASS")

## ----quickstart-manual-family-------------------------------------------------
subset(manual_report$rule_results, family == "Integrity")

## ----quickstart-manual-programmatic-------------------------------------------
any(manual_report$rule_results$status == "FAIL")
manual_report$status_counts

## ----quickstart-render-report, eval=FALSE-------------------------------------
# html_report <- render_report(report)
# html_report

## ----quickstart-save-report, eval=FALSE---------------------------------------
# save_report(report, "goldenviz-report.html")

## ----quickstart-view-report, eval=FALSE---------------------------------------
# view_report(report)

## ----quickstart-expected-report-----------------------------------------------
names(report)

## ----quickstart-report-annotated, echo=FALSE, out.width="100%"----------------
knitr::include_graphics("figures/goldenviz-report-annotated.png")

