将非R对象上传到Dropbox而不使用本地Dropbox目录

时间:2017-08-22 20:01:59

标签: r stargazer

我知道有一个包(rDrop)可以将R对象上传到Dropbox。

我正在使用观星者在干净的HTML表格中整合我的回归。

有没有办法将这些内容上传到Dropbox?那么不是R对象?或者是否有解决方法来完成工作 - 可能是通过定义工作目录?

我面临的主要问题是我正在使用云实例工作,无法在那里安装Dropbox。所以我正在寻找一种上传到Dropbox而无需本地Dropbox目录的方法。

1 个答案:

答案 0 :(得分:1)

您可以使用rDrop2包将任何文件上传到Dropbox - 它只是Dropbox服务的API包装器。

下面是一些伪代码,一旦您使用软件包在自己的计算机上进行身份验证,该代码就可以正常工作:

#load your data
data(iris)

#build your model
mod <- lm(Petal.Width ~ Sepal.Length + Sepal.Width, data=iris)

#save your html 
table_html <- stargazer::stargazer(mod, type = "html")

#write html to disk
write(x = table_html, file = "html_regression.html")

#get most recent version of the rdrop2 package
#not, the package is based on the v1 API which will soon cease to 
#function
install.packages("rdrop2")

#load library and authenticate
library(rdrop2)
drop_auth()

#check directory exists
drop_dir("stargazer_regressions")

#upload your html to dropbox
drop_upload("html_regression.html", dest = "stargazer_regressions")

下面的最终输出:

enter image description here