if(require(BiocInstaller)==FALSE){
source("https://bioconductor.org/biocLite.R")
biocLite()
}
if(require(gistr)==FALSE){
BiocInstaller::biocLite(c("gistr", "dyplr"))
library(gistr)
library(dplyr)
}
Now that you have added the token to your R environment, the functions inside the gistr package can use it to pull your gists.
gists(what = "minepublic")
## [[1]]
## <gist>8c2292d3cf6ae82ed052
## URL: https://gist.github.com/8c2292d3cf6ae82ed052
## Description: Commands and code to run for TT repo
## Public: TRUE
## Created/Edited: 2015-07-01T23:33:41Z / 2015-08-29T14:24:06Z
## Files: addGHrepo.txt
## Truncated?: FALSE
##
## [[2]]
## <gist>26a470449b8acc296ee9
## URL: https://gist.github.com/26a470449b8acc296ee9
## Description: Code for downloading TCGA data
## Public: TRUE
## Created/Edited: 2015-07-01T17:35:53Z / 2015-08-29T14:24:05Z
## Files: exampleTutorial.Rmd
## Truncated?: FALSE
##
## [[3]]
## <gist>f5579c17e9951d09b702
## URL: https://gist.github.com/f5579c17e9951d09b702
## Description: getting started with gistr
## Public: TRUE
## Created/Edited: 2015-06-18T20:29:02Z / 2015-08-29T14:23:20Z
## Files: gistR.R
## Truncated?: FALSE
##
## [[4]]
## <gist>f7a957019e2c7d556275
## URL: https://gist.github.com/f7a957019e2c7d556275
## Description: Code to check if all rows in columns are duplicates
## Public: FALSE
## Created/Edited: 2015-06-12T19:37:04Z / 2015-08-29T14:22:57Z
## Files: isDups.R
## Truncated?: FALSE
##
## [[5]]
## <gist>180046ecbeaa1382ac1f
## URL: https://gist.github.com/180046ecbeaa1382ac1f
## Description: COAD Mutation Example
## Public: FALSE
## Created/Edited: 2015-06-10T21:19:58Z / 2015-08-29T14:22:53Z
## Files: coadMUT.txt
## Truncated?: FALSE
##
## [[6]]
## <gist>0122cef6d984b041207f
## URL: https://gist.github.com/0122cef6d984b041207f
## Description: read.delim vs fread microbenchmark results
## Public: FALSE
## Created/Edited: 2015-03-13T20:17:58Z / 2015-08-29T14:17:04Z
## Files: results.r
## Truncated?: FALSE
##
## [[7]]
## <gist>51f014838a023fc55f0c
## URL: https://gist.github.com/51f014838a023fc55f0c
## Description: Extract all caps between brackets PipeR
## Public: FALSE
## Created/Edited: 2015-03-06T21:08:53Z / 2015-08-29T14:16:41Z
## Files: pipexpl
## Truncated?: FALSE
gists(what = "minepublic")[[1]] %>% browse
gist_create("isDups.R", description = "Code to check if all rows in columns are duplicates", public = FALSE)
The devtools package has a convenient function to source any gist from GitHub. In this example, I source my own gist. The first one in my list of Gists is sourced ([[1]]).
gists(what="minepublic")[[1]]$id %>% devtools::source_gist()
If you make further changes to your gist, you may want to update the uploaded gist from within R.
gists(what="minepublic")[[1]] %>% update_files("isDups.R") %>% update()
Here, I create another gist from a file that I had already worked on. I can add a description to the Gist and tell GitHub to knit the file. As an example, GitHub will not be able to knit an R file.
gist_create("~/Documents/SupportTCGA/exampleTutorial.r", description = "Code for downloading TCGA data", public = TRUE, knit=TRUE)
In order to fix the previous error, I can update the files to the Gist with the update_files function and the correct file name. This time, GitHub will knit the document.
gists(what="minepublic")[[2]] %>% update_files("exampleTutorial.Rmd") %>% update(knit=TRUE)
If I create another gist, the first one in the list will be the last one I have uploaded. They are sorted from recent to old.
gist_create("addGHrepo.txt", description = "Commands and code to run for TT repo", public = TRUE)
gists(what = "minepublic")[[1]] %>% update_files("addGHrepo.txt") %>% update
In order to see your own gist, you will have to enter the appropriate GitHub username and the Gist ID.
baseURL <- "https://gist.github.com"
gitusername <- "LiNk-NY"
gistID <- gists(what="minepublic")[[1]]$id
browseURL(paste(baseURL, gitusername, gistID, sep = "/"))