Installing RStudio ver. 1.4 with Docker

Contents
  1. Removing Docker images
  2. If you are using Docker Compose
  3. Checking the .yml file and Dockerfile
  4. docker-compose.yml
  5. Dockerfile
  6. Running docker-compose up -d
  7. Checking the version
  8. Side note

RStudio 1.4 has been released and is now available for use in Docker. A standout feature in 1.4 is the visual markdown editor. As for using third-party tools like Zotero, you can now easily cite sources from your library via an API.

I spent the morning tinkering with RStudio 1.4. You can now copy and paste tables directly from Excel into the body text, and it integrates with Zotero to insert citekeys. It is simply easy to use as a pure Markdown editor. https://t.co/TX90xoNTJg

— Shoei (@shoei05) January 23, 2021

Removing Docker images

To avoid using the cache, remove the Docker containers and images you are currently using.

If you are using Docker Compose

Please refer to this guide for instructions on how to use Docker Compose.

https://plaza.umin.ac.jp/shoei05/wp/index.php/2020/10/30/196/

Connect via SSH using Terminal (on Mac). On Windows, use TeraTerm((Impress Corporation. Mado no Mori. Mado no Mori. Accessed February 21, 2021. https://forest.watch.impress.co.jp/library/software/utf8teraterm/)) or Windows Terminal((Summary of Features and Usage of the Finally Completed "Windows Terminal". @IT. Accessed February 21, 2021. https://www.atmarkit.co.jp/ait/articles/2005/28/news018.html)). For basic Linux commands, this resource((dotinstall. [Old Version] Introduction to UNIX Commands [General User Edition] (All 24 Lessons). Dotinstall. Accessed February 21, 2021. https://dotinstall.com/lessons/basic_unix_v2)) provides thorough video explanations. Basic commands are also explained in Kameleon's Docker course((Docker Course Taught from Scratch by a US AI Developer. Udemy. Accessed February 21, 2021. https://www.udemy.com/course/aidocker/)).

# 自分(Mac)の場合 /Users/user から /Users/user/Dropbox/docker へ移動

cd Dropbox
cd dockerCode language: PHP (php)

If you are using Windows and want to switch from the C: drive to the D: drive, enter:

D:

Switch to the D: drive first, and then navigate to your target folder.

Once you are in the target folder, use the command below to remove everything created by the `up` command—images, containers, volumes, and networks (reference):

docker-compose down --rmi all --volumes --remove-orphans

Checking the .yml file and Dockerfile

Let's review the `docker-compose.yml` file and `Dockerfile`.

docker-compose.yml

version: '3'

services:
  rstudio:
    build: .
    image: geo:geospatial
    container_name: geo
    ports:
      - 8787:8787
    environment:
      PASSWORD: YOUR_PASS
    volumes:
      - ../R:/home/rstudio
    tty: true
    stdin_open: trueCode language: JavaScript (javascript)

Here, we set the RStudio password using the `environment` option. Change `YOUR_PASS` to any password of your choice.

Dockerfile

Please refer to this article for details about the Dockerfile.

https://plaza.umin.ac.jp/shoei05/wp/index.php/2020/10/17/56/
# ベースとするイメージ(任意のrocker/*に変更可能)
FROM rocker/geospatial:latest

# OS環境(rockerはdebianベース)に日本語ロケールを追加し切り替え
ENV LANG ja_JP.UTF-8
ENV LC_ALL ja_JP.UTF-8
RUN sed -i '$d' /etc/locale.gen \
  && echo "ja_JP.UTF-8 UTF-8" >> /etc/locale.gen \
    && locale-gen ja_JP.UTF-8 \
    && /usr/sbin/update-locale LANG=ja_JP.UTF-8 LANGUAGE="ja_JP:ja"
RUN /bin/bash -c "source /etc/default/locale"
RUN ln -sf  /usr/share/zoneinfo/Asia/Tokyo /etc/localtime

# 日本語フォントをインストール
RUN apt-get update && apt-get install -y \
  fonts-ipaexfont \
  fonts-noto-cjk

# {pacman}のインストール
RUN install2.r --error \
    pacmanCode language: PHP (php)

Here, we install `{pacman}` right from the start. If you do not need it, delete the last three lines.

https://plaza.umin.ac.jp/shoei05/wp/index.php/2020/10/24/145/

Running docker-compose up -d

docker-compose up -d

Enter the above to run Docker Compose.

Recreating geo(container_name) ... done

If it finishes immediately with output like this, the cache is still remaining. Check once more to make sure no images are left behind.

docker images

With the command above, you can check the images that currently remain.

# docker rmi REPOSITORY:TAG で削除
docker rmi geo:geospatialCode language: CSS (css)

Remove the image using a command like the one above, and run `docker-compose up -d` again. Depending on your environment, this will take several minutes, so wait patiently.

I have omitted the fine details, but the process looks roughly like this.

Checking the version

If no errors appear after entering the command above, RStudio has started successfully. Access RStudio at http://localhost:8787, and

if you can confirm from Help > About RStudio that it is Version 1.4, the installation is complete.

Professor @KunisatoY((KunisatoY (@KunisatoY) / Twitter. Twitter. Accessed February 21, 2021. https://twitter.com/KunisatoY)) has shared instructions on how to use the Zotero API in RStudio 1.4. I plan to review this separately at another time.

Citing literature in RStudio
1. Install RStudio v1.4
2. Open an R Markdown file and click the 'A'-like icon on the far right to enter Visual Mode
3. Under Global Options > R Markdown > Citations, set the API key obtained from the Zotero web interface
4. Click the '@'-like icon in Visual Mode to easily cite literature stored in Zotero.

— Yoshihiko Kunisato/国里愛彦 (@KunisatoY) January 22, 2021

Regarding the Japanese input issues in RStudio 1.3, the method below remains effective in 1.4 as well. Alternatively, switching to the visual markdown editor mode seems to allow Japanese input without any problems.

https://plaza.umin.ac.jp/shoei05/wp/index.php/2021/01/03/482/

Side note

On a side note, I recently participated in a group's *mokumoku-kai* (silent study session) for the first time.

A *mokumoku-kai* is a general term for a gathering where people meet in the same place and work or study independently and silently. The name is said to come from the Japanese word *mokumoku-to* (silently).((Pasona Tech, Inc. What is an Engineer's Mokumoku-kai? Is it Useful for Acquiring Knowledge and Networking? | For IT and Manufacturing Engineer Job Changes and Dispatch Information [Pasona Tech]. For IT and Manufacturing Engineer Job Changes and Dispatch Information [Pasona Tech]. Accessed February 21, 2021. https://www.pasonatech.co.jp/workstyle/column/detail.html?p=2282))

I personally tend to get caught up in immediate distractions and procrastinate on my highest-priority tasks. At the recent *mokumoku-kai*, because we had to present our results to everyone at the end of the session, the moderate pressure helped me get my tasks done. I hope to keep making use of opportunities like this.

"List what you need to do and prioritize it into A, B, and C. Further divide A into A1, A2, and A3. When you are working on A2 or A3, you fall under the illusion that you are somehow using your time effectively. Doing A2 or A3 while setting aside A1 is a waste of time. Ultimately, the cause of busyness comes down to procrastinating on what should be your highest priority." https://t.co/p6A20ytud0

— Shoei (@shoei05) December 16, 2020

"The greatest difficulty for self-learners is not so much that they don't know how to study, but that due to various external and internal factors, they cannot continue studying and end up giving up halfway. Most books on studying neglect this most crucial point." https://t.co/NgBJtBao2B

— Shoei (@shoei05) November 6, 2020

"The phrase 'self-study is not solitary study' has various meanings. For one, there is a saying that 'someone reading the same book is far away.' Someone currently studying on their own might think there are no other self-learners nearby. But in reality, they just haven't had the chance to know each other, and there are many of them out there in the world." https://t.co/D4rAl7kxft

— Shoei (@shoei05) January 7, 2021
English translation of the Japanese article.