官术网_书友最值得收藏!

Installing Packages

In this chapter, we've already seen some of the base functions that are built into R. We also built a few custom functions, area_triangle() and area_rectangle(), in the last section.

Now, let's talk about packages. Anyone can write an R package of useful functions and publish it for use by others. Packages are usually made available on the Comprehensive R Archive Network (CRAN) website, or Bioconductor, a collection of packages for bioinformatics and other uses. Both these sites conduct a thorough review of submitted packages before publishing them on their sites, so package developers often keep beta versions of packages, or those that are useful but may not pass the inspections, on GitHub.

RStudio makes installing packages very easy. There are two ways to do so: either type install.packages("package_name") in a script or your console, or you can navigate to the Packages tab in the lower right window and click Install, which will show a window that allows you to type the names of the packages that are available on CRAN. You can even install multiple packages if you separate them with a comma. You'll want to keep Install dependencies checked, as this will install any packages that the package you've chosen depends on to run successfully—you'll want those! Let's see this in the following screenshot:

Let's now use two different methods to install R packages. Follow these steps:

  • Install the survival package using the following code:
install.packages("survival")
  • Install the mice package using the Install button on the Packages tab.

Output: The following should be displayed on your console:

The same information should be displayed once you install mice, with that package's name subbed in for survival.

R and RStudio, plus its packages, are incredibly helpful data science tools that will be the focus of this book. Now, let's get your project for the book set up, and install a set of incredibly useful packages called the Tidyverse, for use throughout the rest of this book.

主站蜘蛛池模板: 霍城县| 宝应县| 杨浦区| 九江县| 乌兰察布市| 宝兴县| 潍坊市| 鸡泽县| 宝应县| 寻乌县| 苗栗市| 来安县| 望城县| 合水县| 阜南县| 红河县| 永泰县| 新安县| 康保县| 高淳县| 葫芦岛市| 逊克县| 镇沅| 屏东市| 汉沽区| 鲁甸县| 三门峡市| 辉南县| 井陉县| 韩城市| 湾仔区| 灵川县| 曲麻莱县| 三都| 湟源县| 响水县| 新宁县| 涪陵区| 横山县| 武乡县| 鄂托克旗|