简体   繁体   English

为R安装conda

[英]install conda for R

I want to use R with Jupyter notebook environment, so i followed the instruction "Jupyter and conda for R" . 我想在Jupyter笔记本环境中使用R,因此我遵循了“ Jupyter and conda for R”的说明

As it said, I've entered following command in cmd 就像我说的那样,我在cmd中输入了以下命令

conda install -c r r-essentials

and the install was successful, when I tries to make a new notebook, I don't see an option for R file. 并且安装成功,当我尝试制作一个新笔记本时,我看不到R文件的选项。

here is the whole install command and result I had in my cmd 这是我在cmd中拥有的整个安装命令和结果

C:\Users\myname>conda install -c r r=3.4.1
Fetching package metadata .............
Solving package specifications: .

Package plan for installation in environment C:\Users\myname\Anaconda3:

The following NEW packages will be INSTALLED:

    m2w64-bwidget:           1.9.10-2
    m2w64-bzip2:             1.0.6-6
    m2w64-expat:             2.1.1-2
    m2w64-fftw:              3.3.4-6
    m2w64-flac:              1.3.1-3
    m2w64-gcc-libgfortran:   5.3.0-6
    m2w64-gcc-libs:          5.3.0-7
    m2w64-gcc-libs-core:     5.3.0-7
    m2w64-gettext:           0.19.7-2
    m2w64-gmp:               6.1.0-2
    m2w64-gsl:               2.1-2
    m2w64-libiconv:          1.14-6
    m2w64-libjpeg-turbo:     1.4.2-3
    m2w64-libogg:            1.3.2-3
    m2w64-libpng:            1.6.21-2
    m2w64-libsndfile:        1.0.26-2
    m2w64-libtiff:           4.0.6-2
    m2w64-libvorbis:         1.3.5-2
    m2w64-libwinpthread-git: 5.0.0.4634.697f757-2
    m2w64-libxml2:           2.9.3-3
    m2w64-mpfr:              3.1.4-4
    m2w64-pcre:              8.38-2
    m2w64-speex:             1.2rc2-3
    m2w64-speexdsp:          1.2rc3-3
    m2w64-tcl:               8.6.5-3
    m2w64-tk:                8.6.5-3
    m2w64-tktable:           2.10-5
    m2w64-wineditline:       2.101-5
    m2w64-xz:                5.2.2-2
    m2w64-zlib:              1.2.8-10
    msys2-conda-epoch:       20160418-1
    r:                       3.4.1-r3.4.1_0       r
    r-base:                  3.4.1-0              r
    r-boot:                  1.3_19-r3.4.1_0      r
    r-class:                 7.3_14-r3.4.1_0      r
    r-cluster:               2.0.6-r3.4.1_0       r
    r-codetools:             0.2_15-r3.4.1_0      r
    r-foreign:               0.8_68-r3.4.1_0      r
    r-kernsmooth:            2.23_15-r3.4.1_0     r
    r-lattice:               0.20_35-r3.4.1_0     r
    r-mass:                  7.3_47-r3.4.1_0      r
    r-matrix:                1.2_10-r3.4.1_0      r
    r-mgcv:                  1.8_17-r3.4.1_0      r
    r-nlme:                  3.1_131-r3.4.1_0     r
    r-nnet:                  7.3_12-r3.4.1_0      r
    r-recommended:           3.4.1-r3.4.1_0       r
    r-rpart:                 4.1_11-r3.4.1_0      r
    r-spatial:               7.3_11-r3.4.1_0      r
    r-survival:              2.41_3-r3.4.1_0      r

The following packages will be UPDATED:

    conda:                   4.3.21-py36_0          --> 4.3.25-py36_0

Proceed ([y]/n)? y

msys2-conda-ep 100% |###############################| Time: 0:00:00 158.41 kB/s
m2w64-expat-2. 100% |###############################| Time: 0:00:00   1.36 MB/s
m2w64-gmp-6.1. 100% |###############################| Time: 0:00:00   7.68 MB/s
m2w64-gsl-2.1- 100% |###############################| Time: 0:00:00  20.72 MB/s
m2w64-libiconv 100% |###############################| Time: 0:00:00  29.93 MB/s
m2w64-libogg-1 100% |###############################| Time: 0:00:00  20.59 MB/s
m2w64-libwinpt 100% |###############################| Time: 0:00:00   2.98 MB/s
m2w64-wineditl 100% |###############################| Time: 0:00:00   7.09 MB/s
m2w64-gcc-libs 100% |###############################| Time: 0:00:00  18.52 MB/s
m2w64-mpfr-3.1 100% |###############################| Time: 0:00:00  18.71 MB/s
m2w64-gcc-libg 100% |###############################| Time: 0:00:00  23.18 MB/s
m2w64-gcc-libs 100% |###############################| Time: 0:00:00  21.36 MB/s
m2w64-bzip2-1. 100% |###############################| Time: 0:00:00  10.25 MB/s
m2w64-fftw-3.3 100% |###############################| Time: 0:00:00  28.86 MB/s
m2w64-flac-1.3 100% |###############################| Time: 0:00:00  26.84 MB/s
m2w64-gettext- 100% |###############################| Time: 0:00:00  24.97 MB/s
m2w64-libjpeg- 100% |###############################| Time: 0:00:00  24.99 MB/s
m2w64-libvorbi 100% |###############################| Time: 0:00:00  25.43 MB/s
m2w64-speexdsp 100% |###############################| Time: 0:00:00  26.09 MB/s
conda-4.3.25-p 100% |###############################| Time: 0:00:00  26.53 MB/s
m2w64-speex-1. 100% |###############################| Time: 0:00:00  25.76 MB/s
m2w64-xz-5.2.2 100% |###############################| Time: 0:00:00  26.13 MB/s
m2w64-zlib-1.2 100% |###############################| Time: 0:00:00   9.59 MB/s
m2w64-libpng-1 100% |###############################| Time: 0:00:00  13.17 MB/s
m2w64-libsndfi 100% |###############################| Time: 0:00:00  20.56 MB/s
m2w64-libtiff- 100% |###############################| Time: 0:00:00  31.69 MB/s
m2w64-libxml2- 100% |###############################| Time: 0:00:00  29.22 MB/s
m2w64-pcre-8.3 100% |###############################| Time: 0:00:00  26.45 MB/s
m2w64-tcl-8.6. 100% |###############################| Time: 0:00:00  18.72 MB/s
m2w64-tk-8.6.5 100% |###############################| Time: 0:00:00   8.62 MB/s
m2w64-bwidget- 100% |###############################| Time: 0:00:00   9.16 MB/s
m2w64-tktable- 100% |###############################| Time: 0:00:00  11.40 MB/s
r-base-3.4.1-0 100% |###############################| Time: 0:01:17 534.84 kB/s
r-boot-1.3_19- 100% |###############################| Time: 0:00:03 217.30 kB/s
r-cluster-2.0. 100% |###############################| Time: 0:00:02 224.80 kB/s
r-codetools-0. 100% |###############################| Time: 0:00:00 102.40 kB/s
r-foreign-0.8_ 100% |###############################| Time: 0:00:02 104.88 kB/s
r-kernsmooth-2 100% |###############################| Time: 0:00:01  94.41 kB/s
r-lattice-0.20 100% |###############################| Time: 0:00:05 162.95 kB/s
r-mass-7.3_47- 100% |###############################| Time: 0:00:18  68.59 kB/s
r-nnet-7.3_12- 100% |###############################| Time: 0:00:01  74.14 kB/s
r-rpart-4.1_11 100% |###############################| Time: 0:00:07 135.56 kB/s
r-spatial-7.3_ 100% |###############################| Time: 0:00:01 124.91 kB/s
r-class-7.3_14 100% |###############################| Time: 0:00:01  86.55 kB/s
r-matrix-1.2_1 100% |###############################| Time: 0:00:11 232.44 kB/s
r-nlme-3.1_131 100% |###############################| Time: 0:00:08 273.08 kB/s
r-mgcv-1.8_17- 100% |###############################| Time: 0:00:08 329.00 kB/s
r-survival-2.4 100% |###############################| Time: 0:00:12 435.97 kB/s
r-recommended- 100% |###############################| Time: 0:00:00 168.20 kB/s
r-3.4.1-r3.4.1 100% |###############################| Time: 0:00:00 212.83 kB/s

That's not all you need to do to have R in Jupyter. 在Jupyter中拥有R并不是您要做的全部。

After you install the packages r and r-essentials you have to install the kernel. 安装软件包rr-essentials ,必须安装内核。 The IRkernel suggested by @matt is the best one in my opinion. 我认为@matt建议的IRkernel是最好的。

To install IRkernel and make it "visible" by Jupyter you can do as instructed in the documentation but I suggest an easier approach that worked for me. 要安装IRkernel并使Jupyter对其“可见”,可以按照文档中的说明进行操作,但是我建议一种更简单的方法对我有用。

  1. Install IRkernel 安装IRkernel

C:\\Users\\myname> conda install r-irkernel

  1. At the command line open R 在命令行中打开R

C:\\Users\\myname> R

  1. Inside R do the following: 在R内执行以下操作:

> IRkernel::installspec(user = FALSE)

  1. Quit R 退出R

> q()

  1. At the command prompt check if the kernel is installed 在命令提示符处检查是否已安装内核

C:\\Users\\myname> jupyter kernelspec list

There should be ir listed as a kernel. 应该将ir列为内核。

  1. Open jupyter and create a new R notebook. 打开jupyter并创建一个新的R笔记本。

You not only need to install R, but you need to tell Jupyter how to communicate with R. One of the possibility is to use the IRkernel . 您不仅需要安装R,而且需要告诉Jupyter如何与R通信。一种可能性是使用IRkernel There are other kernels: R-Brain have another R kernel I've seen at conferences not sure it is publicly available. 还有其他内核: R-Brain还有另一个R内核,我在会议上见过,但不确定它是否公开可用。

The Kernel of your choice will have documentation and instructions on how to register it with Jupyter. 您选择的内核将包含有关如何在Jupyter中进行注册的文档和说明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM