Sign inSign up

ykunisato/ccp-r

By ykunisato

•Updated over 1 year ago

Rstudio server including R packages that are useful for writing articles.

Image
0

1.1K

ykunisato/ccp-r repository overview

⁠Dockerfile of writing paper by R Markdown

This is a repository of Dockerfile for Rstudio server used in Computational Clinical Psychology Lab⁠, including packages and add-ins that are useful for writing articles with R Markdown in Rstudio. This Dockerfile is based on rocker/rstudio. The GitHub repository for this Docker image is: ykunisato/ccp-r⁠.

日本語解説(Japanese)⁠

Maintainer is Yoshihiko Kunisato ([email protected]⁠)

Keywords: psychology, cognitive science, rstudio, stan, rmarkdown, Quarto

⁠Usage

  1. Install "Docker Desktop"⁠

  2. Open "terminal"(Mac) or "PowerShell"(Windows)

  3. Type the following code to pull a Docker container. Change the "password" and "name_of_container" as you like.

Mac(apple silicon)

docker run -e PASSWORD=password -p 8787:8787 -v $(pwd):/home/rstudio -d --name ccpr ykunisato/ccp-r:latest-arm64

or

docker run -e PASSWORD=password -e DISABLE_AUTH=true -p 8787:8787 -v $(pwd):/home/rstudio -d --name ccpr ykunisato/ccp-r:latest-arm64

Mac(intel)

docker run -e PASSWORD=password -p 8787:8787 -v $(pwd):/home/rstudio -d --name ccpr ykunisato/ccp-r:latest-amd64

or

docker run -e PASSWORD=password -e DISABLE_AUTH=true -p 8787:8787 -v $(pwd):/home/rstudio -d --name ccpr ykunisato/ccp-r:latest-amd64

Windows

docker run -e PASSWORD=password -p 8787:8787 -v "%cd%":/home/rstudio -d --name ccpr ykunisato/ccp-r:latest
  1. Open the web browser and type "http://localhost:8787/⁠" in the URL bar.

  2. You will see the Rstudio on the web browser. Type rstudio in ID column and password that you set in password column.

⁠Optional usage

  1. If you use a cmdstan, please execute the following code on R console in the Rstudio.
cmdstanr::install_cmdstan(cores = 2)

Once you have installed CmdStan, please run the following code in R console to verify that it is working properly(I am referring to the cmdstanr website⁠).

# packages
library(cmdstanr)
library(posterior)
library(bayesplot)
color_scheme_set("brightblue")
# Compiling a model
file <- file.path(cmdstan_path(), "examples", "bernoulli", "bernoulli.stan")
mod <- cmdstan_model(file)
# Running MCMC
data_list <- list(N = 10, y = c(0,1,0,0,0,0,0,0,0,1))

fit <- mod$sample(
  data = data_list,
  seed = 123,
  chains = 4,
  parallel_chains = 4,
  refresh = 500 # print update every 500 iters
)
# Result
fit$summary()
mcmc_hist(fit$draws("theta"))
  1. If you use a tinytex, please execute the following code on R console in the Rstudio.
tinytex::install_tinytex()
tinytex::tlmgr_install("haranoaji")

Tag summary

Content type

Image

Digest

sha256:ceb314fd8…

Size

3.6 GB

Last updated

over 1 year ago

docker pull ykunisato/ccp-r:latest-amd64