Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GitHub Codespaces configuration for R and Shiny.

NotificationsYou must be signed in to change notification settings

jakubnowicki/r-codespaces

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repository contains a basic configuration that allows working with R inGitHub Codespaces.It is based on official Github Codespacesdev container for R.It includesR andR LSP Client VSCode extensions.It comes withrenv setup which includeslanguageserver package required to enable the latter extension.To install it, open R in Codespaces console and typerenv::restore().

Adjusting configuration to your needs

Different R version

This configuration is based onrocker/r-ver:4.1.2 Docker image with installed dependencies required bylanguageserver package.You can change that and replace the current image with the one of your choice in.devcontainer/Dockerfile.Checkrocker repositories for available options.

Remember that current Dockerfile is suited for images based on Ubuntu.

Installing R packages

I strongly recommend usingrenv when it comes to setting your working environment in R.This configuration comes with initalized workspace but you can easily create your own one. Just remember thatlanguageserver is required forR LSP Client extension to work (it needs to be installed, adding torenv.lock file is optional).

renv configuration set here as default comes with (already mentioned)languageserver,lintr andstyler packages. To enable detection byrenv, all three are included indevelop_packages.R file. This way you can runrenv::snapshot() without setting any additional option liketype = "all" and include them in your R environment setup.

Adding VSCode extensions

Besides extensions for R, this configuration includes a few additional ones that can be helpful in development.You can add additional extensions in.devcontainer/devcontainer.json file in "extensions" section.

Running Shiny applications

R extension allows running Shiny applications from Codespaces. To do that,follow these steps (you can use sample ShinyOld Faithful app):

  1. Installshiny and all R dependencies required by your app by opening R in Codespace console.
  2. You will need an entry file.
    • In single file apps it is just the samefile as the app (shinyApp(ui = ui, server = server) at the end of the file).
    • In multiple files app you need an additional file withshiny::runApp(appDir = "app_dir") function that points to the app directory.
  3. Run this file withR: Run soure with echo command (shortcut: Ctrl/Cmd + Shift + Enter)
  4. App will be available at a specific port. You can set it as function argument(eg.shiny::runApp(appDir = "app+dir", port = 8888)) or leave it so itwill be chosen randomly. Now you need to forward that port so you can accessthe app in your browser. VSCode Remote extension is super handy here. Itwill list all available ports and you can forward them just by a single click.
  5. Enjoy playing with your app!

About

GitHub Codespaces configuration for R and Shiny.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp