简体   繁体   中英

install conda for R

I want to use R with Jupyter notebook environment, so i followed the instruction "Jupyter and conda for R" .

As it said, I've entered following command in 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.

here is the whole install command and result I had in my 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.

After you install the packages r and r-essentials you have to install the kernel. The IRkernel suggested by @matt is the best one in my opinion.

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.

  1. Install IRkernel

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

  1. At the command line open R

C:\\Users\\myname> R

  1. Inside R do the following:

> IRkernel::installspec(user = FALSE)

  1. Quit 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.

  1. Open jupyter and create a new R notebook.

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 . There are other kernels: R-Brain have another R kernel I've seen at conferences not sure it is publicly available.

The Kernel of your choice will have documentation and instructions on how to register it with Jupyter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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