if( file.exists("~/.Rprofile") ){ source("~/.Rprofile") } require(githubr) token <- Sys.getenv('GITHUBRTOKEN') if(token != ""){ setGithubToken(token) }
GitHub has emerged as a very popular tool for collaborative code development in the software community. The utility of source code repositories expands far beyond use in professional software development. In fact, it has been shown to be extremely useful for a number of other endeavors. The purpose of this package is to provide an interface for users of R to have web-accessible access to their code directly within their R sessions.
Users can use githubr
without authenticating (anonymous calls to the API), however there are limits both to what can be accessed as well as the number of API calls allowed. Please see the GitHub Developer docs for more information on anonymous use of the GitHub API.
For access to private repositories and/or to have an increased limit on the number of API calls, users should register a personal access token with the client via the setGithubToken
function. Personal access tokens can be generated on your GitHub settings page. Give your token a meaningful name, like "githubr token" such that you can remember what it is being used for. Once you have called setGithubToken
, the token passed to this function is then used for all subsequent calls to github api for the current R session.
require(githubr) setGithubToken("myTokenFromGithub12345678")
Include the following information in your .Rprofile
located in your root directory. As this is sensitive information, make sure that this file is only visible to you.
setHook( packageEvent("githubr", "attach"), function(...){ ## set my github authorization at package loading setGithubToken("myTokenFromGithub12345678") } )
repo <- getRepo('brian-bot/githubr') repo
repoDev <- getRepo('brian-bot/githubr', ref='branch', refName='dev') repoDev
repoCommit <- getRepo("brian-bot/githubr", ref="commit", refName="9382e7191073c1a5dc554ec8b6658d07d405b89e") repoCommit
sourceRepoFile(repoDev, "inst/misc/helloWorld.R")
getPermlink(repoDev, "inst/misc/helloWorld.R")
view(repoDev, "inst/misc/helloWorld.R")
sessionInfo()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.