[Framework examples →](../)

# R data loader to generate JPEG

View live: <https://observablehq.observablehq.cloud/framework-example-loader-r-to-jpeg/>

This Observable Framework example demonstrates how to write an R data loader that creates a scatterplot using ggplot2, then outputs the chart as JPEG to standard out. The scatterplot visualizes the relationship between diamond size, cut, and price using the [diamonds](https://ggplot2.tidyverse.org/reference/diamonds.html) dataset. The data loader lives in [`src/data/diamonds.jpeg.R`](./src/data/diamonds.jpeg.R).
