Step 5: Well done, you’ve now created a RStudio project!
Installing packages
Packages are the way R users share useful code. You can think of each R package as a book. Once you’ve installed a package, you can load the code contained in it using
library- which is like checking out a book from the library!
包是 R 用户共享有用代码的方式。你可以把每个 R 包想象成一本书。安装包后,你可以使用 library 加载其中包含的代码——就像从图书馆借书一样!
install.packages(tidyverse)
install.packages(visdat)
What happened when you ran library(tidyverse) at the console?
Do you think that you’ll always need to run that code to use the tidyverse?
Although the tidyverse only needs to be installed once, it must be loaded in every new R session using library(tidyverse) before I can use its functions like glimpse() or filter().
R 是会话式语言,每次启动是全新环境;
安装一次 tidyverse 就够了,但每次使用时都要用 library() 手动加载;
如果你在 R Markdown 文件中用到了 tidyverse,也应该在开头代码块中加载它。
What happened when you ran the code chunk?
When I ran glimpse(diamonds), I saw a vertical summary of the diamonds dataset including each variable’s type and a preview of its values.
Then, when I ran filter(diamonds, carat <= 2.5), R returned a filtered version of the dataset containing only rows where the diamond’s carat is 2.5 or less. This filtered dataset had fewer rows than the original (53,814 instead of 53,940).