Skip to content

Instantly share code, notes, and snippets.

@jamesmaino
jamesmaino / r-plumber-on-aws.md
Last active November 16, 2022 01:31
Create a Plumber API for R code hosted on AWS EC2
View r-plumber-on-aws.md

Deploying an API for an R code base with {plumber} and AWS

This post is largely built around a tutorial by Martin Lukac but this tutorial did not set up a persistent API service so some final steps are adapted from the plumber documentation.

Setup the AWS instance

You start by logging into your AWS account. Once in, you select an RStudio Amazon Machine Image (AMI) from this link. You are free to choose any, but it's more efficient to choose based on your geography. The Rstudio service is actually not really necesary, as all the steps can be done directly from the terminal, but some users might feel more comfortable with it.

Once in AWS, you have to select the machine you want to run it on. AWS EC2 has a free tier option called t2.micro, and that's the one I will be using here. Click Review and Launch

@jamesmaino
jamesmaino / gist:0e459d2d979d36422ed40e89f5301cea
Last active August 16, 2022 02:10
Create new R shiny app in vscode
View gist:0e459d2d979d36422ed40e89f5301cea

Create new R shiny app in vscode

Increasingly I am using vscode instead of RStudio for a consistent coding experience across languages. Here is how to start a new shiny app.

Make a ui.R script to hold the interface.

# Define UI for app that draws a histogram ----
ui <- fluidPage(
@jamesmaino
jamesmaino / github-new-repo.md
Last active February 22, 2023 02:32
Handy github commands
View github-new-repo.md

Create new git with github repo from command line

gh repo create --source=. --public
git init -b main
git add . && git commit -m "initial commit"
git remote add origin  git@github.com:jamesmaino/<REMOTE_PATH>.git
git push 

If you are modifying a cloned repo and what to change the remote origin you personal account use the following.

@jamesmaino
jamesmaino / create-aws-shiny-server.md
Last active September 19, 2022 04:41
Guide to creating a shiny server on AWS that hosts spatial apps with persistent storage
View create-aws-shiny-server.md