Last active
August 19, 2016 21:18
-
-
Save junhe/173ed3fac5b7d5eeded5b9c2506ea161 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This function download my python downloader, and use the downloader to download | |
# the private file from github repository. | |
# Example: | |
# source_r_file_in_git_repos("doraemon", "analysis/analyzer3.r", "44a7fc3f86f621fe8d213bc7d429034d947a656e") | |
source_r_file_in_git_repos <- function(repo_name, file_path, commit) | |
{ | |
target_dir = "/tmp/for_r_analysis_j2jxn6ah" | |
print("downloading the python script that is used to checkout code") | |
system('cd /tmp; curl -O https://gist.githubusercontent.com/junhe/eabc9a6723c786b499868c2b142d5b2d/raw/37710659c74ada5804c02edbe5489752352de452/checkout-repos.py') | |
print("git clone and checkout...") | |
cmd = sprintf("python /tmp/checkout-repos.py --repo_name %s --target_dir %s --commit %s", | |
repo_name, target_dir, commit) | |
system(cmd) | |
repos_path = file.path(target_dir, repo_name) | |
setwd(repos_path) | |
local_path = file_path | |
print(local_path) | |
# sourcing the downloaded file | |
print(paste("sourcing the downloaded file:", local_path)) | |
source(local_path) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment