top of page

R Programming Journal Module 9 - Wesley Huang

  • Writer: Wesley Huang
    Wesley Huang
  • Mar 23
  • 1 min read

In this assignment, I compared three different visualization systems in R: base graphics, lattice, and ggplot2. I used the built in iris dataset, which includes measurements such as sepal length, sepal width, petal length, and species. Using the same dataset for all three systems made it easier to see how each visualization method works and how the output differs.

For base R graphics, I created a scatter plot using the plot() function. This approach was the most straightforward and required the least setup. However, it also required more manual adjustments for styling and customization. It works well for quick visualizations but is more limited in flexibility.

Next, I used lattice graphics with the xyplot() function to create a conditioned scatter plot by species. This system made it easier to separate the data into multiple panels based on categories. Compared to base R, lattice is better for grouped visualizations, but the syntax is slightly different and takes some getting used to.


Finally, I used ggplot2 to create a scatter plot with a regression line grouped by species. ggplot2 uses a layered approach, which made it very flexible and easier to customize. Out of all three systems, ggplot2 produced the most polished and professional looking visualization with relatively simple code.

The main difference between the three systems is how they structure the plotting process. Base R uses direct function calls, lattice uses formulas and conditioning, and ggplot2 builds plots in layers. ggplot2 provided the most control and best visual output, while base R was the simplest and fastest to use. Lattice was useful for grouped comparisons but was less intuitive than ggplot2.


 
 
 

Comments


bottom of page