Finding my Dropbox in R
[This article was first published on R – Stat Bandit, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
I’ll often keep non-sensitive data on Dropbox so that I can access it on all my machines without gumming up git. I just wrote a small script to find the Dropbox location on each of my computers automatically. The crucial information is available here, from Dropbox.
My small snippet of code is the following:
if (Sys.info()['sysname'] == 'Darwin') { info <- RJSONIO::fromJSON( file.path(path.expand("~"),'.dropbox','info.json')) } if (Sys.info()['sysname'] == 'Windows') { info <- RJSONIO::fromJSON( if (file.exists(file.path(Sys.getenv('APPDATA'), 'Dropbox','info.json'))) { file.path(Sys.getenv('APPDATA'), 'Dropbox', 'info.json') } else { file.path(Sys.getenv('LOCALAPPDATA'),'Dropbox','info.json') } ) } dropbox_base <- info$personal$path
I haven’t included the Linux option since I don’t really use a Linux box, but the Dropbox link above will show you where the info.json file lies in Linux. Also, if you have a business Dropbox account, you’ll probably need info$business$path
.
Hope this helps!!!
To leave a comment for the author, please follow the link and comment on their blog: R – Stat Bandit.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.