Coder Social home page Coder Social logo

r-codespaces's Introduction

GitHub Codespaces configuration for R

This repository contains a basic configuration that allows working with R in GitHub Codespaces. It is based on official Github Codespaces dev container for R. It includes R and R LSP Client VSCode extensions. It comes with renv setup which includes languageserver package required to enable the latter extension. To install it, open R in Codespaces console and type renv::restore().

Adjusting configuration to your needs

Different R version

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

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

Installing R packages

I strongly recommend using renv 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 that languageserver is required for R LSP Client extension to work (it needs to be installed, adding to renv.lock file is optional).

renv configuration set here as default comes with (already mentioned) languageserver, lintr and styler packages. To enable detection by renv, all three are included in develop_packages.R file. This way you can run renv::snapshot() without setting any additional option like type = "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 Shiny Old Faithful app):

  1. Install shiny 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 same file as the app (shinyApp(ui = ui, server = server) at the end of the file).
    • In multiple files app you need an additional file with shiny::runApp(appDir = "app_dir") function that points to the app directory.
  3. Run this file with R: 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 it will be chosen randomly. Now you need to forward that port so you can access the app in your browser. VSCode Remote extension is super handy here. It will list all available ports and you can forward them just by a single click.
  5. Enjoy playing with your app!

r-codespaces's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

r-codespaces's Issues

Basic help

Thanks so much for putting this together. I copied your devcontainer-json folder and put it into my root directory of my github repo that has codespaces enabled. I waited for 30 mins for the session to time out and then spun it up, but I still get the message “linux can’t use R” when I execute my R code.

What am I doing wrong? Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.