Skip to content

Instantly share code, notes, and snippets.

@apreshill
Created October 5, 2018 16:47
Show Gist options
  • Save apreshill/91c3e8acffaab6604c85139145fef164 to your computer and use it in GitHub Desktop.
Save apreshill/91c3e8acffaab6604c85139145fef164 to your computer and use it in GitHub Desktop.
my solution
# Create a GitHub PAT
# Hint: use the usethis package
# see: http://happygitwithr.com/github-pat.html#step-by-step
library(usethis)
browse_github_pat() # takes you to browser
# Add it to .Renviron
# Hint: use the usethis package
edit_r_environ() # makes the file if not yet made- needs blank line at end!
# now copy/paste long PAT with = sign
# GITHUB_PAT=8c70fd8419398999c9ac5bacf3192882193cadf2
# restart r and check it is there
Sys.getenv("GITHUB_PAT")
# Upload your solution as a gist using the GitHub API
# https://developer.github.com/v3/gists/#create-a-gist
# Hint: use the gh package
# Hint: for POST requests, use named parameters, for the files object use a
# named list e.g. `list(filename = list(content = xyz))`
library(gh)
gh::gh("POST /gists",
description = "my solution",
public = TRUE,
files = list(
"12-startup-alison.R" = list(content = readr::read_file("12-startup-01.R"))
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment