conda creates an R environment:
conda create -n lry_R4.2.2 conda activate lry_R4.2.2 conda install -c conda-forge r-base=4.2.2
After installation, enter R to run R. Exit and enter q(); In the R environment, you can install the corresponding R package. The corresponding R package can be installed in the R environment. Or use conda to install, such as the installation package
ggplot2
conda install r-ggplot2#R packages usually need to start with r-
Install the R package management tool conda-forge in the conda environment:
conda install -c conda-forge r-irkernel
This command installs the IRkernel package, a Jupyter kernel for the R language that can run R code in Jupyter Notebook or JupyterLab.
Install jupyter notebook.
pip install jupyter notebook
After installation, start Jupyter Notebook but the following information will be prompted:
Command jupyter’ not found, but can be installed with:
sudo snap install jupyter # version 1.0.0, or
sudo apt install jupyter-core # version 4.6.3-3
See snap info jupyter’ for additional versions.
After installing through this command, start it.
sudo snap install jupyter
After starting, you can use python, but the R environment is not yet successful. I did the following but it still doesn’t work.
install.packages(“devtools”)
Select a region, any place in China, I choose 25;
The installation was unsuccessful and an error was reported: The installation of ragg also had the same error.
fatal error: ft2build.h: No such file or directory
Also install the following
sudo apt-get install libgtk-3-dev
Still getting an error, libtiff4 is missing; install it as follows
sudo apt-get install libtiff-dev
Still error:
Configuration failed to find one of freetype2 libpng libtiff-4 libjpeg. Try installing: * deb: libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev (Debian, Ubuntu, etc) * rpm: freetype-devel libpng-devel libtiff-devel libjpeg-devel (Fedora, CentOS, RHEL) * csw: libfreetype_dev libpng16_dev libtiff_dev libjpeg_dev (Solaris) If freetype2 libpng libtiff-4 libjpeg is already installed, check that 'pkg-config' is in your PATH and PKG_CONFIG_PATH contains a freetype2 libpng libtiff-4 libjpeg.pc file. If pkg-config is unavailable you can set INCLUDE_DIR and LIB_DIR manually via: R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
Then continue to install the following dependency projects:
sudo apt-get install -y libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev
Or not. Continue installation
conda install -c conda-forge pkg-config
ragg was finally installed successfully. Installing devtools
Finally the installation was successful:
Use the mirror tool to download and install the R kernel from the github website:
devtools::install_github('IRkernel/IRkernel')
Register and activate R kernel in R
IRkernel::installspec() # to register the kernel in the current R installation
but unsuccessfully:
> IRkernel::installspec() Traceback (most recent call last): File "/snap/jupyter/6/bin/jupyter-kernelspec", line 10, in <module> sys.exit(KernelSpecApp.launch_instance()) File "/snap/jupyter/6/lib/python3.7/site-packages/traitlets/config/application.py", line 658, in launch_instance app.start() File "/snap/jupyter/6/lib/python3.7/site-packages/jupyter_client/kernelspecapp.py", line 273, in start return self.subapp.start() File "/snap/jupyter/6/lib/python3.7/site-packages/jupyter_client/kernelspecapp.py", line 143, in start replace=self.replace, File "/snap/jupyter/6/lib/python3.7/site-packages/jupyter_client/kernelspec.py", line 346, in install_kernel_spec shutil.copytree(source_dir, destination) File "/snap/jupyter/6/lib/python3.7/shutil.py", line 315, in copytree names = os.listdir(src) FileNotFoundError: [Errno 2] No such file or directory: '/tmp/Rtmp7kyPFR/filea6b207c3f2c/kernelspec'
Then don’t use this method and install Rstudio server;
Follow this process to install:
https://www.cnblogs.com/liujiaxin2018/p/16215241.html
Note: What I need is an environment in which I have installed R2.2.2. Then I need to make modifications. First, check the path of R.
R.home() [1] "/home/jx-vmlab/miniconda3/envs/lry_R4.2.2/lib/R"
Write the R path to the Rstudio configuration file and enter the following content.
sudo vim /etc/rstudio/rserver.conf
# Server Configuration File rsession-which-r=/home/jx-vmlab/miniconda3/envs/lry_R4.2.2/lib/R
Stop the service through rstudio-server stop. After configuration, restart. rstudio-server restart
rstudio-server status
Check the status, whether it is active (running)
The previous version will be replaced with the current version; the installation will be successful.
But an error occurs when importing installed packages
Error: package or namespace load failed for destiny’ in dyn.load(file, DLLpath = DLLpath, ...): Unable to load shared target object '/home/jx-vmlab/miniconda3/envs/lry_R4.2.2/lib/R/library/Rcpp/libs/Rcpp.so':: /lib/x86_64-linux-gnu/libstdc + + .so.6: version `GLIBCXX_3.4.29' not found (required by /home/jx-vmlab/miniconda3/envs/lry_R4.2.2/lib/R/library/ Rcpp/libs/Rcpp.so)
The solution is as follows:
conda install libgcc export LD_LIBRARY_PATH=/home/jx-vmlab/miniconda3/envs/lry_R4.2.2/lib:$LD_LIBRARY_PATH cd /home/jx-vmlab/miniconda3/envs/lry_R4.2.2/lib ln -s libstdc++ .so.6.0.32 libstdc++ .so.6
you can add export LD_LIBRARY_PATH=/path/to/anaconda/envs/myenv/lib:$LD_LIBRARY_PATH to ~/.bashrc file.
If it still doesn’t work in rstudio-server:
Please refer to the following. After certain settings, you need to restart rstudio-server;
I took it as a reference and that’s it.
https://blog.csdn.net/phdsky/article/details/84104769
The solution is as follows: After a day of doing this, the letter makes me miserable. I will stay with you forever.
You can also refer to this, to solve the problem, also refer to the above link.
https://cloud.tencent.com/developer/article/1819222