Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@yutannihilation
Last active February 14, 2017 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yutannihilation/e95f3ba3643e3936682591d53acc2c41 to your computer and use it in GitHub Desktop.
Save yutannihilation/e95f3ba3643e3936682591d53acc2c41 to your computer and use it in GitHub Desktop.
---
title: "test"
author: "yutannihilation"
date: "2017年2月14日"
output:
html_document:
self_contained: false
---
```{r test, results='hide'}
# Gistをつくる
g <- gistr::gist_create(code = "dummy", filename = "dummy", browse = FALSE)
g$delete_files <- list("dummy")
g <- gistr::update(g)
# HTTP APIではバイナリファイルをアップロードできないのでgitプロトコルを使う
repo <- git2r::clone(g$git_pull_url, local_path = tempfile("gist"))
gist_upload <- function(file) {
# ファイルをコピーしてコミットするだけ
file.copy(file, to = repo@path)
git2r::add(repo, basename(file))
git2r::commit(repo, basename(file))
git2r::push(repo, credentials = git2r::cred_env("GITHUB_USERNAME", "GITHUB_PAT"))
basename(file)
}
knitr::opts_knit$set(upload.fun = gist_upload,
base.url = sprintf("https://gist.githubusercontent.com/%s/%s/raw/", g$owner$login, g$id))
```
```{r plot1}
plot(iris)
```
```{r plot2}
plot(mtcars)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment