작성자: admin 작성일시: 2016-09-19 23:52:26 조회수: 368 다운로드: 55
카테고리: R 태그목록:

R 패키지 설치하기

라이브러리와 패키지

집을 지을 때, 시멘트나 철근이 필요하다고 해서 집을 짓는 사람이 시멘트 제작이나 철광석 제련부터 할 수는 없다. 대부분의 건축에 공통적으로 사용되는 부품이나 재료는 이미 만들어진 것을 사서 쓰는 것이 효율적이다.

프로그램도 마찬가지어서 필요한 모든 부분을 한 사람이 만드는 경우는 거의 없으며 여러가지 프로그램에 공통적으로 사용되는 부분은 해당 분야의 전문가가 미리 만들어 놓은 프로그램을 가져다 사용하는 것이 현명한 선택이다. 이렇게 다른 프로그램 제작에 사용하기 위해 미리 만들어진 프로그램의 집합을 라이브러리(library)라고 한다. R에서는 라이브러리라는 용어 대신 패키지(package)라는 말을 주로 사용한다.

설치된 패키지 확인하기

현재 컴퓨터에 설치되어 있는 패키지를 확인하려면 installed.packages 명령을 사용한다.

In:
installed.packages()
PackageLibPathVersionPriorityDependsImportsLinkingToSuggestsEnhancesLicenseLicense_is_FOSSLicense_restricts_useOS_typeMD5sumNeedsCompilationBuilt
BiocInstallerBiocInstaller /usr/local/lib/R/site-library 1.22.3 NA R (>= 3.3.0) NA NA devtools, RUnit, BiocGenerics NA Artistic-2.0 NA NA NA NA no 3.3.1
IRkernelIRkernel /usr/local/lib/R/site-library 0.7 NA R (>= 3.2.0) repr (>= 0.4.99), methods, evaluate (>= 0.5.4), IRdisplay (>= 0.3.0.9999), pbdZMQ (>= 0.2-1), crayon, jsonlite (>= 0.9.6), uuid, digest NA testthat, roxygen2 NA MIT + file LICENSE NA NA NA NA NA 3.3.1
rChartsrCharts /usr/local/lib/R/site-library 0.4.5 NA NA plyr, lattice, RCurl, RJSONIO, whisker, yaml NA NA NA MIT NA NA NA NA NA 3.3.1
rhdf5rhdf5 /usr/local/lib/R/site-library 2.16.0 NA methods zlibbioc NA bit64,BiocStyle NA Artistic-2.0 NA NA NA NA yes 3.3.1
zlibbioczlibbioc /usr/local/lib/R/site-library 1.18.0 NA NA NA NA NA NA Artistic-2.0 + file LICENSE NA NA NA NA yes 3.3.1
littlerlittler /usr/lib/R/site-library 0.3.1 NA NA NA NA knitr, docopt, rcmdcheck NA GPL (>= 2) NA NA unix NA yes 3.3.1
RcppRcpp /usr/lib/R/site-library 0.11.0 NA R (>= 3.0.0) methods NA RUnit, inline, rbenchmark, highlight NA GPL (>= 2) NA NA NA NA NA 3.0.2
abindabind /usr/lib/R/library 1.4-5 NA R (>= 1.5.0) methods, utils NA NA NA LGPL (>= 2) NA NA NA NA no 3.3.1
assertthatassertthat /usr/lib/R/library 0.1 NA NA NA NA testthat NA GPL-3 NA NA NA NA no 3.3.1
basebase /usr/lib/R/library 3.3.1 base NA NA NA methods NA Part of R 3.3.1 NA NA NA NA NA 3.3.1
base64encbase64enc /usr/lib/R/library 0.1-3 NA R (>= 2.9.0) NA NA NA png GPL-2 | GPL-3 NA NA NA NA yes 3.3.1
BHBH /usr/lib/R/library 1.60.0-2 NA NA NA NA NA NA BSL-1.0 NA NA NA NA no 3.3.1
bitopsbitops /usr/lib/R/library 1.0-6 NA NA NA NA NA NA GPL (>= 2) NA NA NA NA yes 3.3.1
bootboot /usr/lib/R/library 1.3-18 recommended R (>= 3.0.0), graphics, stats NA NA MASS, survival NA Unlimited NA NA NA NA no 3.3.1
carcar /usr/lib/R/library 2.1-3 NA R (>= 3.2.0) MASS, mgcv, nnet, pbkrtest (>= 0.4-4), quantreg, grDevices, utils, stats, graphics NA alr4, boot, coxme, leaps, lme4, lmtest, Matrix, MatrixModels, nlme, rgl (>= 0.93.960), sandwich, SparseM, survival, survey NA GPL (>= 2) NA NA NA NA no 3.3.1
caretcaret /usr/lib/R/library 6.0-71 NA R (>= 2.10), lattice (>= 0.20), ggplot2 car, foreach, methods, plyr, nlme, reshape2, stats, stats4, utils, grDevices NA BradleyTerry2, e1071, earth (>= 2.2-3), fastICA, gam, ipred, kernlab, klaR, MASS, ellipse, mda, mgcv, mlbench, MLmetrics, nnet, party (>= 0.9-99992), pls, pROC (>= 1.8), proxy, randomForest, RANN, spls, subselect, pamr, superpc, Cubist, testthat (>= 0.9.1)NA GPL (>= 2) NA NA NA NA yes 3.3.1
caToolscaTools /usr/lib/R/library 1.17.1 NA R (>= 2.2.0) bitops NA MASS, rpart NA GPL-3 NA NA NA NA yes 3.3.1
chronchron /usr/lib/R/library 2.3-47 NA R (>= 2.12.0) graphics, stats NA scales, ggplot2 zoo GPL-2 NA NA NA NA yes 3.3.1
classclass /usr/lib/R/library 7.3-14 recommended R (>= 3.0.0), stats, utils MASS NA NA NA GPL-2 | GPL-3 NA NA NA NA yes 3.3.1
clustercluster /usr/lib/R/library 2.0.4 recommended R (>= 3.0.1) graphics, grDevices, stats, utils NA MASS NA GPL (>= 2) NA NA NA NA yes 3.3.1
codetoolscodetools /usr/lib/R/library 0.2-14 recommended R (>= 2.1) NA NA NA NA GPL NA NA NA NA no 3.3.1
colorspacecolorspace /usr/lib/R/library 1.2-6 NA R (>= 2.13.0), methods graphics NA KernSmooth, MASS, kernlab, mvtnorm, vcd, dichromat, tcltk NA BSD_3_clause + file LICENSE NA NA NA NA yes 3.3.1
compilercompiler /usr/lib/R/library 3.3.1 base NA NA NA NA NA Part of R 3.3.1 NA NA NA NA NA 3.3.1
crayoncrayon /usr/lib/R/library 1.3.2 NA NA grDevices, methods, utils NA testthat NA MIT + file LICENSE NA NA NA NA no 3.3.1
cubaturecubature /usr/lib/R/library 1.1-2 NA NA NA NA NA NA GPL (>= 2) NA NA NA NA yes 3.3.1
curlcurl /usr/lib/R/library 2.1 NA R (>= 3.0.0) NA NA testthat (>= 1.0.0), knitr, jsonlite, rmarkdown, magrittr NA MIT + file LICENSE NA NA NA NA yes 3.3.1
datasetsdatasets /usr/lib/R/library 3.3.1 base NA NA NA NA NA Part of R 3.3.1 NA NA NA NA NA 3.3.1
data.tabledata.table /usr/lib/R/library 1.9.6 NA R (>= 2.14.1) methods, chron NA ggplot2 (>= 0.9.0), plyr, reshape, reshape2, testthat (>= 0.4), hexbin, fastmatch, nlme, xts, bit64, gdata, GenomicRanges, caret, knitr, curl, zoo, plm NA GPL (>= 2) NA NA NA NA yes 3.3.1
DBIDBI /usr/lib/R/library 0.5-1 NA R (>= 2.15.0), methods NA NA testthat, RSQLite, knitr, rmarkdown, covr NA LGPL (>= 2) NA NA NA NA no 3.3.1
DEoptimRDEoptimR /usr/lib/R/library 1.0-6 NA NA stats NA NA robustbase GPL (>= 2) NA NA NA NA no 3.3.1
157sourcetools /usr/lib/R/library 0.1.5 NA R (>= 3.0.2) NA NA testthat NA MIT + file LICENSE NA NA NA NA yes 3.3.1
158SparseM /usr/lib/R/library 1.72 NA R (>= 2.15), methods graphics, stats, utils NA NA NA GPL (>= 2) NA NA NA NA yes 3.3.1
159spatial /usr/lib/R/library 7.3-11 recommended R (>= 3.0.0), graphics, stats, utils NA NA MASS NA GPL-2 | GPL-3 NA NA NA NA yes 3.3.1
160splines /usr/lib/R/library 3.3.1 base NA graphics, stats NA Matrix, methods NA Part of R 3.3.1 NA NA NA NA NA 3.3.1
161stabledist /usr/lib/R/library 0.7-1 NA R (>= 3.1.0) stats NA Matrix, fBasics, FMStable, RUnit, Rmpfr, sfsmisc NA GPL (>= 2) NA NA NA NA no 3.3.1
162stats /usr/lib/R/library 3.3.1 base NA utils, grDevices, graphics NA MASS, Matrix, SuppDists, methods, stats4 NA Part of R 3.3.1 NA NA NA NA NA 3.3.1
163stats4 /usr/lib/R/library 3.3.1 base NA graphics, methods, stats NA NA NA Part of R 3.3.1 NA NA NA NA NA 3.3.1
164stringi /usr/lib/R/library 1.1.1 NA R (>= 2.13.1) tools, utils, stats NA NA NA file LICENSE yes NA NA NA yes 3.3.1
165stringr /usr/lib/R/library 1.1.0 NA R (>= 2.14) stringi (>= 0.4.1), magrittr NA testthat, knitr, htmltools, htmlwidgets, rmarkdown, covr NA GPL-2 NA NA NA NA no 3.3.1
166survival /usr/lib/R/library 2.39-5 recommended R (>= 2.13.0) graphics, Matrix, methods, splines, stats, utils NA NA NA LGPL (>= 2) NA NA NA NA yes 3.3.1
167tcltk /usr/lib/R/library 3.3.1 base NA utils NA NA NA Part of R 3.3.1 NA NA NA NA NA 3.3.1
168tibble /usr/lib/R/library 1.2 NA R (>= 3.1.2) methods, assertthat, utils, lazyeval (>= 0.1.10), Rcpp Rcpp testthat, withr, knitr (>= 1.5.32), rmarkdown, nycflights13, microbenchmark NA MIT + file LICENSE NA NA NA NA yes 3.3.1
169tidyr /usr/lib/R/library 0.6.0 NA R (>= 3.1.0) tibble, dplyr (>= 0.4), stringi, lazyeval, magrittr, Rcpp Rcpp knitr, testthat, covr, gapminder, rmarkdown NA MIT + file LICENSE NA NA NA NA yes 3.3.1
170timeDate /usr/lib/R/library 3012.100 NA R (>= 2.15.1), graphics, utils, stats, methods NA NA date, RUnit NA GPL (>= 2) NA NA NA NA no 3.3.1
171timeSeries /usr/lib/R/library 3022.101.2 NA R (>= 2.10), graphics, grDevices, stats, methods, utils, timeDate (>= 2150.95) NA NA RUnit, robustbase, xts, PerformanceAnalytics, fTrading NA GPL (>= 2) NA NA NA NA no 3.3.1
172tools /usr/lib/R/library 3.3.1 base NA NA NA codetools, methods, xml2 NA Part of R 3.3.1 NA NA NA NA NA 3.3.1
173truncnorm /usr/lib/R/library 1.0-7 NA R (>= 2.15.0) NA NA NA NA GPL-2 NA NA NA NA yes 3.3.1
174tseries /usr/lib/R/library 0.10-35 NA R (>= 2.10.0) graphics, stats, utils, quadprog, zoo NA its NA GPL-2 NA NA NA NA yes 3.3.1
175TTR /usr/lib/R/library 0.23-1 NA NA xts (>= 0.9-3), zoo xts RUnit quantmod GPL-2 NA NA NA NA yes 3.3.1
176urca /usr/lib/R/library 1.3-0 NA R (>= 2.0.0), methods nlme, graphics, stats NA NA NA GPL (>= 2) NA NA NA NA yes 3.3.1
177utils /usr/lib/R/library 3.3.1 base NA NA NA methods, XML NA Part of R 3.3.1 NA NA NA NA NA 3.3.1
178uuid /usr/lib/R/library 0.1-2 NA R (>= 2.9.0) NA NA NA NA MIT + file LICENSE NA NA NA NA yes 3.3.1
179VarianceGamma /usr/lib/R/library 0.3-1 NA R (>= 2.3.0), DistributionUtils, GeneralizedHyperbolic, RUnit NA NA NA NA GPL (>= 2) NA NA NA NA no 3.3.1
180whisker /usr/lib/R/library 0.3-2 NA NA NA NA markdown NA GPL-3 NA NA NA NA no 3.3.1
181withr /usr/lib/R/library 1.0.2 NA R (>= 3.0.2) stats, graphics NA testthat NA GPL (>= 2) NA NA NA NA no 3.3.1
182XML /usr/lib/R/library 3.98-1.4 NA R (>= 2.13.0), methods, utils NA NA bitops, RCurl NA BSD_2_clause + file LICENSE NA NA NA NA yes 3.3.1
183xtable /usr/lib/R/library 1.8-2 NA R (>= 2.10.0) stats, utils NA knitr, lsmeans, spdep, splm, sphet, plm, zoo, survival NA GPL (>= 2) NA NA NA NA no 3.3.1
184xts /usr/lib/R/library 0.9-7 NA zoo (>= 1.7-10) NA NA timeSeries,timeDate,tseries,its,chron,fts,tis NA GPL (>= 2) NA NA NA NA yes 3.3.1
185yaml /usr/lib/R/library 2.1.13 NA NA NA NA testthat NA BSD_3_clause + file LICENSE NA NA NA NA yes 3.3.1
186zoo /usr/lib/R/library 1.7-13 NA R (>= 2.10.0), stats utils, graphics, grDevices, lattice (>= 0.20-27) NA coda, chron, DAAG, fts, its, ggplot2, mondate, scales, strucchange, timeDate, timeSeries, tis, tseries, xts NA GPL-2 | GPL-3 NA NA NA NA yes 3.3.1

패키지 설치

패키지는 원래 R과는 별도로 설치해야 한다. 몇몇 패키지는 R을 설치할 때 같이 설치되며 이러한 패키지를 기본 패키지라고 한다. 그러나 대부분의 패키지는 R을 설치한 후에 별도로 설치한다.

패키지를 설치하는 명령어는 다음과 같다.

install.packages("패키지이름")

예를 들어 Quandl이라는 이름의 패키지를 설치하려면 다음과 같이 명령한다.

패키지 설치가 처음이라면 패키지를 다운로드할 서버를 선택하라는 주문이 나올 수 있다. 이 때는 선호하는 서버의 번호를 입력하거나 선호 서버가 없는 경우 1을 입력한다.


> install.packages("Quandl")
Installing package into '/usr/local/lib/R/site-library'
(as 'lib' is unspecified)

--- Please select a CRAN mirror for use in this session ---
HTTPS CRAN mirror

 1: 0-Cloud [https]                    2: Algeria [https]
 3: Australia (Melbourne) [https]      4: Australia (Perth) [https]
 5: Austria [https]                    6: Belgium (Ghent) [https]
 7: Brazil (SP 1) [https]              8: Bulgaria [https]
 9: Canada (MB) [https]               10: Chile [https]
11: China (Beijing 4) [https]         12: Colombia (Cali) [https]
13: Czech Republic [https]            14: Denmark [https]
15: France (Lyon 1) [https]           16: France (Lyon 2) [https]
17: France (Marseille) [https]        18: France (Paris 2) [https]
19: Germany (Falkenstein) [https]     20: Germany (Mnster) [https]
21: Iceland [https]                   22: Ireland [https]
23: Italy (Padua) [https]             24: Japan (Tokyo) [https]
25: Malaysia [https]                  26: Mexico (Mexico City) [https]
27: New Zealand [https]               28: Norway [https]
29: Philippines [https]               30: Russia (Moscow) [https]
31: Serbia [https]                    32: Spain (A Corua) [https]
33: Spain (Madrid) [https]            34: Switzerland [https]
35: Taiwan (Chungli) [https]          36: Turkey (Denizli) [https]
37: UK (Bristol) [https]              38: UK (Cambridge) [https]
39: UK (London 1) [https]             40: USA (CA 1) [https]
41: USA (IA) [https]                  42: USA (KS) [https]
43: USA (MI 1) [https]                44: USA (TN) [https]
45: USA (TX) [https]                  46: USA (WA) [https]
47: (HTTP mirrors)

Selection: 1

trying URL 'https://cloud.r-project.org/src/contrib/Quandl_2.8.0.tar.gz'
Content type 'unknown' length 19390 bytes (18 KB)
==================================================
downloaded 18 KB

* installing *source* package 'Quandl' ...
** package 'Quandl' successfully unpacked and MD5 sums checked
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (Quandl)

The downloaded source packages are in
        '/tmp/RtmpKEcB1h/downloaded_packages'

질문/덧글

아직 질문이나 덧글이 없습니다. 첫번째 글을 남겨주세요!