2DegreesInvesting / coding-helpdesk

Live support by appointment
0 stars 0 forks source link

Setup an developer environment running RStudio #37

Closed maurolepore closed 1 year ago

maurolepore commented 1 year ago

User story:

As someone new to 2DII I would like to have a developer environment running RStudio on the cloud, so that I can work with 2DII repos from my web browser and regardless my local OS.

@ysherstyuk here are the steps I did today parallel to you during out meeting. I may be missing or changing something a bit but I hope this leaves a record in case we need it.

I created a Docker droplet on DigitalOcean and connected to it.

ssh root@64.226.79.196:8788

Once in that droplet I run a docker container from the rocker/verse (related resoruces: repo and videos).

docker run -d --name yana -v /mnt:/mnt  -p 8788:8787 -e ROOT=true -e PASSWORD=***** rocker/verse

This makes RStudio available at http://64.226.79.196:8788/ with username "rstudio" and my password.

I Introduced myself to Git (resource):

git config --global user.name "Mauro Lepore"
git config --global user.email "maurolepore@gmail.com"

I then installed the gh CLI with the instructions for Ubuntu Linux (i.e. the OS of the droplet) and autenticated with gh auth login.

In the RStudio terminal I created two directories that I normally use

cd ~
mkdir Downloads
mkdir git

Then I cloned a repo into my newly created ~/git/ directory

cd ~/git
gh repo clone 2DegreesInvesting/tiltData

From RStudio's Files panel I navigated to the tiltData repo and opened the project by clicling tiltData.Rproj

Once in tiltData I first installed the R package pak, then used it to install all the dependencies of tiltData.

install.packages("pak")
pak::local_install_deps()

Two packages were missing so I installed them directly.

pak::pak("janitor")
pak::pak("here")

I donwloaded the tiltData release containing the "raw-ish" database (documented here).

cd ~/Downloads
gh release download v0.0.4.9001 --repo 2DegreesInvesting/tiltData

I was now able to run tests, checks, and knit data-raw/01_wrangle.Rmd and data-raw/02_check.Rmd.

I use the gh CLI for many things, e.g. from a new branch (with one or more commits) I can create a PR with gh pr create.

Install the text editor nano and configure Git to use it (rather than the unfriendly default vim).

sudo apt-get update
sudo apt-get install nano

git config --global core.editor "nano"