GNU/Linux >> Linux の 問題 >  >> Debian

Debian10にRをインストールする方法

Rは、オープンソースのプログラミング言語であり、統計計算とグラフィック表現を専門とする無料の環境です。これは、R Foundation for Statistics Computingによってサポートされており、主に統計ソフトウェアの開発とデータ分析の実行のために統計家とデータマイニング担当者によって使用されます。

この記事では、Debian10にRをインストールする方法について説明します。

前提条件#

このチュートリアルを続行する前に、次の前提条件を満たしていることを確認してください。

  • 少なくとも1GのRAMを搭載したDebian10システム。マシンのRAMが1GB未満の場合は、スワップファイルを作成できます。
  • sudo権限を持つユーザーとしてログインしています。

DebianへのRのインストール#

DebianリポジトリのRパッケージはしばしば時代遅れです。 CRANが管理するリポジトリからRをインストールします。

Debian 10にRをインストールするには、次の手順に従います。

次の手順では、Debian10に最新の安定バージョンのRをインストールする方法について説明します。

  1. HTTPS経由で新しいリポジトリを追加するために必要なパッケージをインストールします:

    sudo apt install dirmngr apt-transport-https ca-certificates software-properties-common gnupg2
  2. 次のコマンドを実行してCRANリポジトリを有効にし、システムにCRANGPGキーを追加します。

    sudo apt-key adv --keyserver keys.gnupg.net --recv-key 'E19F5F87128899B192B1A2C2AD5F960A256A04AF'sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/debian buster-cran35/'
  3. パッケージリストを更新し、Rパッケージをインストールします:

    sudo apt updatesudo apt install r-base
  4. Rバージョンを印刷してインストールを確認します:

    R --version

    この記事を書いている時点で、Rの最新の安定バージョンはバージョン3.6.3です:

    R version 3.6.3 (2020-02-29) -- "Holding the Windsock"
    Copyright (C) 2020 The R Foundation for Statistical Computing
    Platform: x86_64-pc-linux-gnu (64-bit)
    
    R is free software and comes with ABSOLUTELY NO WARRANTY.
    You are welcome to redistribute it under the terms of the
    GNU General Public License versions 2 or 3.
    For more information about these matters see
    https://www.gnu.org/licenses/.

CRANからのRパッケージのインストール#

Rが非常に人気がある主な理由の1つは、Comprehensive R Archive Network(CRAN)を通じて利用できるパッケージのビデオアレイです。

まだインストールしていない場合は、build-essentialをインストールしてください Rパッケージのコンパイルに必要なツールを含むパッケージ:

sudo apt install build-essential

Rの場合 バイナリはrootまたはsudoとして起動され、パッケージはグローバルにインストールされ、すべてのシステムユーザーが利用できます。ユーザーのパーソナルライブラリを設定するには、通常のユーザーとしてバイナリを呼び出します。

例として、stringrという名前のパッケージをインストールします 、一般的な文字列操作の高速で正しい実装を提供します。

ルートとしてRコンソールを開きます:

sudo -i R
R version 3.5.1 (2018-07-02) -- "Feather Spray"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> 

以下のコマンドは、Rコンソール内で実行されます。

stringrをインストールします パッケージ:

install.packages("stringr")

インストールには時間がかかります。完了したら、ライブラリをロードします:

library(stringr)

tutorialという名前の単純な文字ベクトルを作成します :

tutorial <- c("How", "to", "Install", "R", "on", "Debian", "9")

文字列の長さを出力する次の関数を実行します。

str_length(tutorial)
[1] 3 2 7 1 2 6 1

その他のRパッケージは、CRANパッケージページで見つけることができ、install.packages()を使用してインストールできます。 。


Debian
  1. Debian 10(バスター)のインストール方法

  2. Python3.9をDebian10にインストールする方法

  3. Debian10にTeamViewerをインストールする方法

  1. Debian10にMemcachedをインストールする方法

  2. Debian9にGitをインストールする方法

  3. Debian9にGoをインストールする方法

  1. Debian9にPipをインストールする方法

  2. Debian9にRをインストールする方法

  3. Debian9にRubyをインストールする方法