嘻嘻,今天还是比较轻松的!
前些日子刚自学了R的一些基础知识,所以今天就是看一些包的作用以及模仿别人做一些图图!
1.tidyverse
install.packages("tidyverse")#安装
library(tidyverse)#载入(使用前一定要先载入哈)
> ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
> ✔ ggplot2 3.3.2 ✔ purrr 0.3.4
> ✔ tibble 3.0.3 ✔ dplyr 1.0.2
> ✔ tidyr 1.1.2 ✔ stringr 1.4.0
> ✔ readr 1.4.0 ✔ forcats 0.5.0
> ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
> ✖ dplyr::filter() masks stats::filter()
> ✖ dplyr::lag() masks stats::lag()
2.通过help()和“??包的名字”来获取帮助
3.使用gglot2跟着作图试试手感
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy))
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, color = class))
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, size = class))
Left
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, alpha = class))
Right
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, shape = class))
个人感觉还是得自己手动练习,光看还是不行的!
加油!继续努力!