table of Contents
Reference 1
1. packet classification
R package (package) are usually two:
classification | Explanation | Remark |
---|---|---|
binary package | This packet belongs to give the ready to use (ready-to-use), but with the platform-dependent, i.e., under different Win and Linux platforms. | |
Source package | Such packages can be used across platforms, but need to deal with before or compiled (compiled) |
2. Common Functions
function | Explanation | Remark |
---|---|---|
.libPaths() | Check the installation directory packages | If there are multiple lib, install.packages () by default is installed in the first directory |
library() | View package directory already installed | |
library (mypackage) | Loading mypackage package | |
getOption(“defaultPackages”) | View start automatically loaded when the R package. | |
help(package = ‘mypackage’) | View 'mypackage' help | |
args(function) | View function parameters | |
example(function) | The auto-run function helps examples in the documentation, it is praise! | |
demo(“package”) | Show some package demostration | |
vignette ( 'mypackage') | Some packages, especially packages have bioconductor vignette, with a view function | |
openVignette ( 'mypackage') | This function can also view vignette, better use some | |
RSiteSearch(“helpinfor”) | "Helpinfor" relevant information on the R site search | |
help.start() | View detailed HTML document package has been installed, this command is very cool | |
search() | View currently loaded packages | |
sessionInfo() | See package loaded in R | |
methods() | S3 view a generic function of all methods in all methods or a class (S3: S version 3) | |
showMethods(class = “myClass”) | View S4 class method | |
findMethods(“myMethods”) | Check method code | |
class(myObject) | View an object of class | |
getClass(“class/package”) | View the contents of a specific class or package | |
getSlots(“class”) | View a class of slot | |
slotNames(MyObject) | View an object's slot | Myobject @ slotNames can be used to access the object slot value, this design is too cool, continuous use |
Query information in the package | ||
?function/method | View the details of a "function" or "method" of | |
class?graph::graph | View "group" of the details of a case in point. The source of this example is when a query graph package to see which class of information, input ?? a graph after graph :: graph-class | |
ls ( "package: mypackage") | View "mypackage" all objects |
3. Source package installation method
3.1 Method a: local package installation
- The input terminal # R & lt /.../mypackage.tar.gz the CMD the INSTALL
use this method, it is necessary to solve the problem of package dependencies, i.e. install this package depends package installation process prompted
3.2 Method Two: Online installation
- May also be used in install.packages R () function is mounted, and relatively simple, i.e., networking can be installed, it can be installed with
, if there are multiple lib, install.packages () is mounted in the first default directory
> install.packages('mypackage')
- You may be used install.packages () installed locally downloaded package, the package is particularly suitable for installation on the server
# 举个栗子
> install.packages(c("XML_0.99-5.tar.gz", "http://www.cnblogs.com/Interfaces/Perl/RSPerl_0.8-0.tar.gz"), repos = NULL, configure.args = c(XML = '--with-xml-config=xml-config', RSPerl = "--with-modules='IO Fcntl'"))
3.3 Bioconductor installation method
> source("http://bioconductor.org/biocLite.R")
> biocLite("mypackage")
Uninstall package
> remove.packages("mypackage")
View R version of its package
> R.version
_
platform x86_64-pc-linux-gnu
arch x86_64
os linux-gnu
system x86_64, linux-gnu
status
major 3
minor 3.3
year 2017
month 03
day 06
svn rev 72310
language R
version.string R version 3.3.3 (2017-03-06)
nickname Another Canoe
> packageVersion("utils")
[1] ‘3.3.3’
Update package
The following can be performed on a regular basis
> update.packages( )
Others use the installation package
修改.bashrc文件,添加环境变量R的lib路径
# 别人的包路径
export R_LIBS=/home/.../R/lib64/R/library
R中用.libPaths()函数查看lib路径,如果有多个lib,install.packages()默认是安装在第一个目录下