From the course: Creating Reports and Presentations with R Markdown and RStudio
Unlock the full course today
Join today to access over 22,700 courses taught by industry experts or purchase this course individually.
ggplot2 and plots in R Markdown documents - RStudio Tutorial
From the course: Creating Reports and Presentations with R Markdown and RStudio
ggplot2 and plots in R Markdown documents
- [Instructor] It's a slight simplification, but in R there are essentially two types of charts. They're base R charts created with the graphics package, and ggplot2 charts created with ggplot2 package built by Hadley Wickham. A typical example of the base R plot is the bar chart that would be generated with the bar plot function. Where as with ggplot2 charts, the chart always begins with ggplot2, and we add geoms and other layers to the chart with a plus symbol. It's important to note that both types of chart can be inserted into R Markdown documents by constructing the relevant chart in a code chunk. Similarly, the appearance of charts in R Markdown output is controlled by the same code chunk options for both ggplot2 and base R charts. For instance, if we want to control the size of the chart, we would use the same chunk option regardless of whether we're creating a ggplot2 chart or a chart from base R.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.