【问题标题】:How Automate Script in R using taskscheduleR?如何使用 taskscheduleR 自动化 R 中的脚本?
【发布时间】:2021-08-20 19:46:08
【问题描述】:

我目前正在查看此documentation 以使用 R 和 taskscheduleR 在我的机器上自动执行脚本。我对以下文档感到困惑:

在文档中的示例中,什么是“extdata”,这应该是我的 R 脚本的文件路径,而“helloworld.R”是实际的 R 脚本吗?

myscript <- system.file("extdata", "helloworld.R", package = "taskscheduleR")

我目前对此的看法如下:其中 C:/Users/santi/Documents/R Scripts 是我的文件路径,Wayerhaeuser_Automation_script.R 是我的实际 R 脚本

myscript <- system.file("C:/Users/santi/Documents/R Scripts", "Wayerhaeuser_Automation_script.R", package = "taskscheduleR")

taskscheduler_create(taskname = "myfancyscript", rscript = myscript, 
                     schedule = "ONCE", starttime = format(Sys.time() + 62, "%H:%M"))

我对它的文档有点困惑。

尝试建议的解决方案后尝试:

【问题讨论】:

    标签: r automation taskscheduler windows-task-scheduler


    【解决方案1】:

    myscript 更改为:

    myscript <- paste0("C:/Users/santi/Documents/R Scripts/","Wayerhaeuser_Automation_script.R")
    
    

    它应该可以正常工作。 rscript 参数只是要运行的文件的字符串路径。如果有空格,有时路径会被错误解释,所以如果它不起作用,也可以尝试将文件夹名称更改为 R_Scripts

    【讨论】:

    • 谢谢我这样做了,脚本没有运行。在我的任务调度程序上次运行结果列中,我收到了0x1 的消息,我不确定这意味着什么。我会用截图更新问题
    • 这可能会对您有所帮助,它可能与 Windows stackoverflow.com/questions/18370547/… 上的权限有关
    • 谢谢,我已按照指示进行操作,现在收到directory name is invalid 错误。如果我理解正确,是否需要在 Start in (optional): area 中明确键入 Program/Script?
    猜你喜欢
    • 2018-05-27
    • 2020-02-26
    • 2017-11-08
    • 2018-04-04
    • 2021-11-23
    • 1970-01-01
    • 2020-10-09
    • 2012-12-29
    • 2020-12-26
    相关资源
    最近更新 更多