我可以将我的R输出(.jpeg)保存到FTP服务器吗? [英] Can I save my R output (.jpeg) to an FTP server?

查看:198
本文介绍了我可以将我的R输出(.jpeg)保存到FTP服务器吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(可选阅读)更高的目标:PowerBI Web )或云存储(安全和开源),然后将其导入到PowerBI.此解决方法可能会解决程序包冲突(希望).

(optional read) Greater Objective: PowerBI Web doesn't support a few R packages when published on the internet. It throws the below error ("Missing R Package"). Hence, I am working towards saving the output from R as an image (.jpeg) to a remote location (such as FTP) or cloud storage (secure and open source) and then import it to PowerBI. This workaround might resolve the package conflict (hoping).

特定目标 *:以下代码说明了一种在本地保存R输出(.jpeg)图像的简单方法.但是,如果我有用户名/密码等,是否可以将图像直接保存到FTP服务器? (很遗憾,我无法共享服务器详细信息)

Specific Objective*: The below code illustrates a trivial way of saving an R output(.jpeg) image locally. However, is there a way to save the image directly to the FTP server, provided I have the username/password etc? (unfortunately, I cannot share the server details)

library(outbreaks)
library(incidence)

cases = subset(nipah_malaysia, select = c("perak", "negeri_sembilan", "selangor",
                                           "singapore"))

i = as.incidence(cases, dates = nipah_malaysia$date, interval = 7L)
jpeg(file = "plot.jpeg")
plot(i)
dev.off()

我确实遇到过关于使用"rcurl"包中的ftpUpload功能的文章.但是,要将其上传到FTP,我可能仍需要将其保存在本地,这在本用例中无法达到我的目的.

I did come across this post on employing ftpUpload function from the "rcurl" package. However, to upload it to FTP, I might still need to save it locally which defeats my purpose in this use-case.

任何建议都会有所帮助.

Any suggestions would be helpful.

推荐答案

如果可以选择保存临时文件(如您在注释中所建议),则可以使用以下代码进行保存:

If saving a temporary file (as you suggested in a comment) is an option, then you can do that with the following code:

library(outbreaks)
library(incidence)
library(RCurl)

cases = subset(nipah_malaysia, select = c("perak", "negeri_sembilan", "selangor",
                                           "singapore"))

i = as.incidence(cases, dates = nipah_malaysia$date, interval = 7L)
jpeg(file = filename <- tempfile())
plot(i)
dev.off()
ftpUpload(filename, "ftp://User:Password@FTPServer/destfile.jpeg")

这篇关于我可以将我的R输出(.jpeg)保存到FTP服务器吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆