This project demonstrates how to create clear, informative plots using both ggplot2 and base R graphics. You’ll find scripts that load and clean data, generate visualisations, and export them as images and a PDF.
data-viz/
├── .Rproj.user/ # RStudio project files (do not edit)
├── data/ # Raw and cleaned data files
│ └── …
├── data-viz.Rproj # RStudio project descriptor
├── data-viz-project-script-1.R # ggplot2 script
├── data-viz-project-script-2.R # Base-R script
├── dimonds-areaplot.png # Example ggplot2 output
├── scatterplot.png # Example base-R output
└── area.pdf # High-resolution ggplot2 area plot
- R (version 4.0.0 or above)
- RStudio (recommended)
- R packages:
tidyverseinspectdfjanitorbulkreadr
You can install the required packages with:
install.packages(c("tidyverse", "inspectdf", "janitor", "bulkreadr"))-
Clone the repository
git clone https://github.com/your-username/data-viz.git cd data-viz -
Open the project Double-click
data-viz.Rprojin RStudio to load the project environment. -
Run the scripts Run each script line by line
-
data-viz-project-script-1.R
- Loads and cleans the data
- Uses ggplot2 to build a layered area chart
- Exports the result to
dimonds-areaplot.pngandarea.pdf
-
data-viz-project-script-2.R
- Prepares the data for the base graphics
- Uses base R plotting syntax to build chart
- Saves the figure as scatterplot.png
- scatterplot.png — a quick exploratory scatter plot
- dimonds-areaplot.png — a polished ggplot2 area chart
- area.pdf — publication-quality version of the area chart
Place any raw data files (for example diamonds.csv) in the data/ folder. The scripts assume that files in data/ are ready to be read with readr::read_csv().
Contributions are welcome. Please open an issue or submit a pull request with improvements or bug fixes.
This project is released under the MIT Licence.