Slidev logo
00:03

Introduction

ggplot2 is a system for declaratively creating graphics, based on The Grammar of Graphics. You provide the data, tell ggplot2 how to map variables to aesthetics, what graphical primitives to use, and it takes care of the details.

ggplot2 是一个基于图形语法声明式创建图形的系统。您提供数据,告诉 ggplot2 如何将变量映射到美学,使用什么图形代码,它会处理细节。

The tidyverse is an opinionated collection of R packages designed for data science. All packages share an underlying design philosophy, grammar, and data structures.

ggplot2 是 tidyverse 的一部分,也就是说我们安装 tidyverse 的时候,ggplot2 也会被安装。

Installation

install.packages("tidyverse") # Install tidyverse
library(tidyverse) # Load tidyverse

Source: The Tidyverse · Teach Data Science. (2024, January 18). Retrieved from https://teachdatascience.com/tidyverse

current

大家应该都已经安装好了tidyverse,如果没有安装,可以通过install.packages("tidyverse")安装。

tidyverse是一个数据科学的R包集合,所有的包都共享一个基础的设计理念、语法和数据结构。

也就是说,我们可以通过tidyverse中的其他包来读取和清理数据,然后再通过ggplot2来作图。我们这节课主要是讲ggplot2,所以我就不介绍tidyverse中的其他包了。