R – 重复执行脚本

我有一个R脚本,用于进行特定的Twitter搜索,并将结果连同时间戳添加到数据框中。我希望能够安排这个脚本每隔五分钟运行一次。有没有办法在R中实现这个功能?


回答:

如果你使用的是Linux机器,可以使用cron作业(链接在此)。在基于Windows的机器上,有一个名为任务计划程序的工具(链接在此)可以使用。通过这些工具,你可以调用RScript,它允许你从命令行执行R脚本(在Linux上较旧版本的R可能需要使用R CMD,如果是这样,我建议你更新R)。以下是Rscript的帮助信息:

Usage: /path/to/Rscript [--options] [-e expr] file [args]--options accepted are  --help              Print usage and exit  --version           Print version and exit  --verbose           Print information on progress  --default-packages=list                      Where 'list' is a comma-separated set                        of package names, or 'NULL'or options to R, in addition to --slave --no-restore, such as  --save              Do save workspace at the end of the session  --no-environ        Don't read the site and user environment files  --no-site-file      Don't read the site-wide Rprofile  --no-init-file      Don't read the user R profile  --restore           Do restore previously saved objects at startup  --vanilla           Combine --no-save, --no-restore, --no-site-file                        --no-init-file and --no-environ'file' may contain spaces but not shell metacharacters

tcltk2也允许你使用tclTask从正在运行的R控制台中安排任务。这也是一个值得考虑的选项。

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注