Как установить пакет Quantmod в R на ОС UBUNTU? - PullRequest
0 голосов
/ 01 февраля 2020
> install.packages("quantmod")
Installing package into ‘/home/yugandhar/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
also installing the dependencies ‘xts’, ‘zoo’, ‘TTR’

trying URL 'https://cloud.r-project.org/src/contrib/xts_0.12-0.tar.gz'
Content type 'application/x-gzip' length 540698 bytes (528 KB)
==================================================
downloaded 528 KB

trying URL 'https://cloud.r-project.org/src/contrib/zoo_1.8-7.tar.gz'
Content type 'application/x-gzip' length 861309 bytes (841 KB)
==================================================
downloaded 841 KB

trying URL 'https://cloud.r-project.org/src/contrib/TTR_0.23-6.tar.gz'
Content type 'application/x-gzip' length 309148 bytes (301 KB)
==================================================
downloaded 301 KB

trying URL 'https://cloud.r-project.org/src/contrib/quantmod_0.4-15.tar.gz'
Content type 'application/x-gzip' length 150327 bytes (146 KB)
==================================================
downloaded 146 KB

* installing *source* package ‘zoo’ ...
** package ‘zoo’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I../inst/include    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-k1TtL4/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c coredata.c -o coredata.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I../inst/include    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-k1TtL4/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c init.c -o init.o
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I../inst/include    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-k1TtL4/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c lag.c -o lag.o
gcc -std=gnu99 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o zoo.so coredata.o init.o lag.o -L/usr/lib/R/lib -lR
installing to /home/yugandhar/R/x86_64-pc-linux-gnu-library/3.6/00LOCK-zoo/00new/zoo/libs
** R
** demo
** inst
** byte-compile and prepare package for lazy loading
Error: package ‘lattice’ was installed by an R version with different internals; it needs to be reinstalled for use with this R version
Execution halted
ERROR: lazy loading failed for package ‘zoo’
* removing ‘/home/yugandhar/R/x86_64-pc-linux-gnu-library/3.6/zoo’
Warning in install.packages :
  installation of package ‘zoo’ had non-zero exit status
ERROR: dependency ‘zoo’ is not available for package ‘xts’
* removing ‘/home/yugandhar/R/x86_64-pc-linux-gnu-library/3.6/xts’
Warning in install.packages :
  installation of package ‘xts’ had non-zero exit status
ERROR: dependencies ‘xts’, ‘zoo’ are not available for package ‘TTR’
* removing ‘/home/yugandhar/R/x86_64-pc-linux-gnu-library/3.6/TTR’
Warning in install.packages :
  installation of package ‘TTR’ had non-zero exit status
ERROR: dependencies ‘xts’, ‘zoo’, ‘TTR’ are not available for package ‘quantmod’
* removing ‘/home/yugandhar/R/x86_64-pc-linux-gnu-library/3.6/quantmod’
Warning in install.packages :
  installation of package ‘quantmod’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/RtmpncnfvK/downloaded_packages’

1 Ответ

1 голос
/ 01 февраля 2020

Просто выполните sudo apt-get install r-cran-quantmod для более простой автоматической двоичной установки.

Пример использования Docker

Сначала я запускаю Docker (просто чтобы показать это, я фактически запускаю Ubuntu сам )

edd@rob:~$ docker run --rm -ti ubuntu:eoan bash                                                                                                                                                                    
root@80b47bc0afe0:/# apt-get update
Get:1 http://security.ubuntu.com/ubuntu eoan-security InRelease [97.5 kB]
Get:2 http://archive.ubuntu.com/ubuntu eoan InRelease [255 kB]                       
Get:3 http://security.ubuntu.com/ubuntu eoan-security/restricted amd64 Packages [11.0 kB]
Get:4 http://security.ubuntu.com/ubuntu eoan-security/universe amd64 Packages [67.4 kB]
Get:5 http://security.ubuntu.com/ubuntu eoan-security/multiverse amd64 Packages [1075 B]
Get:6 http://security.ubuntu.com/ubuntu eoan-security/main amd64 Packages [162 kB]
Get:7 http://archive.ubuntu.com/ubuntu eoan-updates InRelease [97.5 kB]                   
Get:8 http://archive.ubuntu.com/ubuntu eoan-backports InRelease [88.8 kB]
Get:9 http://archive.ubuntu.com/ubuntu eoan/main amd64 Packages [1277 kB]
Get:10 http://archive.ubuntu.com/ubuntu eoan/multiverse amd64 Packages [188 kB]
Get:11 http://archive.ubuntu.com/ubuntu eoan/universe amd64 Packages [11.6 MB]
Get:12 http://archive.ubuntu.com/ubuntu eoan/restricted amd64 Packages [22.7 kB]
Get:13 http://archive.ubuntu.com/ubuntu eoan-updates/universe amd64 Packages [113 kB]
Get:14 http://archive.ubuntu.com/ubuntu eoan-updates/main amd64 Packages [252 kB]
Get:15 http://archive.ubuntu.com/ubuntu eoan-updates/restricted amd64 Packages [11.0 kB]
Get:16 http://archive.ubuntu.com/ubuntu eoan-updates/multiverse amd64 Packages [1075 B]
Get:17 http://archive.ubuntu.com/ubuntu eoan-backports/universe amd64 Packages [3071 B]
Fetched 14.3 MB in 3s (4326 kB/s)                            
Reading package lists... Done
root@80b47bc0afe0:/#

Вы можете следовать за этим sudo apt-get install r-cran-quantmod. В пустой Docker контейнер без R он установит довольно много пакетов:

root@80b47bc0afe0:/# sudo apt-get install r-cran-quantmod
[... lots omitted for brevity ...]
0 upgraded, 398 newly installed, 0 to remove and 14 not upgraded.
Need to get 249 MB of archives.
After this operation, 1119 MB of additional disk space will be used.

, но хорошие новости - это просто работает. (И вы можете, конечно, с контейнером, в котором уже есть R, см., Например, контейнеры из проекта Rocker.)

У нас есть больше деталей для вас с архивами пакетов .deb (так называемые PPA), специфицирующими c для Ubuntu, но сейчас, возможно, просто начните с пакета из вашего дистрибутива.

Иллюстрация

После загрузки пакетов:

root@80b47bc0afe0:/# Rscript -e 'library(quantmod)'
Loading required package: xts
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

Registered S3 method overwritten by 'xts':
  method     from
  as.zoo.xts zoo 
Loading required package: TTR
Registered S3 method overwritten by 'quantmod':
  method            from
  as.zoo.data.frame zoo 
Version 0.4-0 included new data defaults. See ?getSymbols.
root@80b47bc0afe0:/# 

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...