Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save MarkEdmondson1234/853831411169d554ec7f4d377d7e5dbb to your computer and use it in GitHub Desktop.

Select an option

Save MarkEdmondson1234/853831411169d554ec7f4d377d7e5dbb to your computer and use it in GitHub Desktop.

Revisions

  1. @mwhitaker mwhitaker created this gist Jan 13, 2017.
    30 changes: 30 additions & 0 deletions knit_cloudstorage.rmd
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    ---
    title: "Host image files on Google Cloud storage"
    author: "Michael Whitaker"
    date: "January 12, 2017"
    output:
    html_document:
    self_contained: false
    ---

    ```{r setup, include=FALSE}
    library(knitr)
    library(googleCloudStorageR)
    opts_chunk$set(echo = TRUE)
    opts_knit$set(upload.fun = function(file) {
    upload_try <- gcs_upload(file, name = basename(file), predefinedAcl = "publicRead")
    paste0("https://storage.googleapis.com/BUCKETNAME/",upload_try$name)
    })
    ```

    ## R Markdown

    The function in the above chunk uploads any generated images and adds the src URL automatically in the generated HTML file. Just change to your **BUCKETNAME**

    This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

    When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

    ```{r cars}
    plot(cars)
    ```