View, uninstall, install and uninstall R packages

01. Uninstall your own ancient package

check your package

mypackages <- installed.packages()[,c('Package','Version','LibPath')] %>% as.data.frame()
write.csv(mypackages, "~/Desktop/mypackages.csv")

Find the R package you want to uninstall from the saved document

remove.packages(c("BSgenome.Athaliana.TAIR.TAIR9", "BSgenome.Hsapiens.UCSC.hg19", "GenomeInfoDb", "GenomeInfoDbData", "GenomicAlignments", "GenomicFeatures", "GenomicRanges", "GO.db", "GSEABase", "KEGGgraph", "KEGGREST", "learnr", "RgoogleMaps", "RSQLite", "yeastRNASeq", "yyplot"), lib = .libPaths()[1])
remove.packages(c("IRdisplay", "IRkernel"), lib = .libPaths()[2])

mypackages <- installed.packages()[,c('Package','Version','LibPath')] %>% as.data.frame()
write.csv(mypackages, "~/Desktop/mypackages_new.csv")

After checking, the above packages have been uninstalled.

02. Supplementary section

View loaded packages

(.packages())

remove loaded packages

detach("package:RMySQL")

Note that it is uninstallation, not uninstallation, that is to say, it does not completely delete the package from the R runtime environment, but just does not want the package to be loaded and used.

Useful for checking functional dependencies when packages use function conflicts.

Installation package

install.packages("TSA")

List the path of the library where the package is located

.libPaths()

package loading

library() 或 require()

After installing the package, you need to load it to use the functions in it. At this time, no quotation marks are used in the brackets. The difference between the two is that library() does not return any information after loading, while require() returns TRUE after loading, so require() is suitable for program writing.

package update

update.packages()

Completely remove installed packages:

remove. packages(c("pkg1","pkg2") , lib = file.path("path", "to", "library"))

View installed packages

installed.packages()[,c('Package','Version','LibPath')]

Among them, c('Package','Version','LibPath') means to display the package name, version, and library path information. If there is no [,c('Package','Version','LibPath')] parameter, it will display all information.

View the functions provided by a package

help(package='TSA')



Author: LeoinUSA
Link: https://www.jianshu.com/p/6358091a5683
Source: Jianshu
The copyright belongs to the author. For commercial reprint, please contact the author for authorization, for non-commercial reprint, please indicate the source.

Guess you like

Origin blog.csdn.net/qq_52813185/article/details/131949975