R language and data analysis (6)-R package installation

Browse R package categories:

Insert picture description here
Find the category
Insert picture description here
Genetics. The R package
Insert picture description here
is provided under the sub- category of Genetics. For biological data, the Bioconductor package is more important. It is used to process biological data and was developed by one of the authors of R.
Insert picture description here

  • We can see that so many expansion packs of R have greatly expanded the functions of R, making R can be applied to all walks of life, but so many expansion packs are not easy for novices to find suitable expansion packs, because R packages are too There are more, and many functions are similar, and the naming is not standardized. The learning of many R packages is more complicated than learning R itself, which greatly increases the cost of learning R
  • We can only master the basic R learning first, and then master the R expansion package in practice
  • Each expansion package is equivalent to an app of the mobile phone. We can install different apps to expand the functions of the system, but the installation of the R package is not as easy as the appstore installation

Installation of R extension pack

There are two ways to install the R package

1.Networked online installation(Recommended, because the dependencies between packages can be resolved automatically, most packages can be done with one command)

  • Use function:install.packages (the name of the package)

  • The first time you use the install.packages() function, you will be prompted to choose a mirror site. The R official has a CRAN site. Executing this command without parameters will display a list of CRAN mirror sites. Just select one of the mirror sites.
    Insert picture description here

  • After selecting, you will see a list of all available packages
    Insert picture description here
    Strings in R must be quoted, otherwise an error will be reported
    Insert picture description here
    Automatic download and installation...
    Insert picture description here
    Insert picture description here
    Sometimes the mirror site may not be accessible. At this time, we need to modify the default mirror site.
    Online installation will install the R package into the default directory of the software, so that it is easier to call the package
    The .libPaths() function can display the location of the library
    Insert picture description here
    ==library()==Without any parameters, it can show which installation packages are in the library.
    Most R packages can be installed successfully through online installation, and the required dependency packages can be installed automatically, and only a few need to be installed in advance. Good dependency packages can be installed automatically

2.Install from source code(Linux)

  • Generally, for security on the server, you can only use the source code installation method if you cannot access the network.

  • First, go to the official site or mirror site of R to download the source code of the required R package
    Insert picture description here

  • Then, you need to pay special attention to the dependency problem. If you know the dependency in advance, you need to download the dependent package first, and then upload it to the server. You can use itRcmdinstallCommand to install
    Insert picture description here

  • Install "ABC Analysis", this package needs to depend on the "plottrix" package
    Insert picture description here
    Insert picture description here

Guess you like

Origin blog.csdn.net/qq_44520665/article/details/113697828