- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想使用R(系统)的命令调用.exe程序(spi_sl_6.exe),但是我无法使用“系统”向程序输入参数。下面是我的命令和参数:system("D:\\working\spi_sl_6.exe")
我在网上找了很久。但是没有用。请帮助或尝试提供一些想法如何实现这一目标。提前致谢。
最佳答案
这是使用来自 http://drought.unl.edu/MonitoringTools/DownloadableSPIProgram.aspx .
这似乎提供了一个使用 Windows 的可行解决方案(但并非没有警告!)
首先下载软件和示例文件
# Create directory to download software
mydir <- "C:\\Users\\david\\spi"
dir.create(mydir)
url <- "http://drought.unl.edu/archive/Programs/SPI"
download.file(file.path(url, "spi_sl_6.exe"), file.path(mydir, "spi_sl_6.exe"), mode="wb")
# Download example files
download.file(file.path(url, "SPI_samplefiles.zip"), file.path(mydir, "SPI_samplefiles.zip"))
# extract one example file, and write out
temp <- unzip(file.path(mydir, "SPI_samplefiles.zip"), "wymo.cor")
dat <- read.table(temp)
# Use this file as an example input
write.table(dat, file.path(mydir,"wymo.cor"), col.names = FALSE, row.names = FALSE)
从上面链接的帮助文件 basic-spi-program-information.pdf 的第 3 页开始,命令行代码的格式应为 spi 3 6 12 <infile.dat >outfile.dat
, 然而,以下均无效(仅通过命令行而不是在 R 中),以及如何传递参数的各种迭代。
C:\Users\david\spi\spi_sl_6 3 <C:\Users\david\spi\wymo.cor >C:\Users\david\spi\out.dat
cd C:\Users\david\spi && spi_sl_6 3 <wymo.cor >out.dat
但是,使用来自 Running .exe file with multiple parameters in c# 的已接受答案似乎工作。这又是来自命令行
cd C:\Users\david\spi && (echo 2 && echo 3 && echo 6 && echo wymo.cor && echo out1.dat) | spi_sl_6
因此,要在 R 中运行它,您可以将其包装在 shell
中(您需要将路径更改为保存 exe 的位置)
shell("cd C:\\Users\\david\\spi && (echo 2 && echo 3 && echo 6 && echo wymo.cor && echo out2.dat) | spi_sl_6", intern=TRUE)
out1.dat
和 out2.dat
应该是一样的。
这会引发警告消息,我认为来自 echo
(在 R 中但不是来自命令行)但生成了输出文件。
假设你可以自动执行所有的回声调用,那么你需要做的就是输入时间参数。
timez <- c(2, 3, 6)
stime <- paste("echo", timez, collapse =" && ")
infile <- "wymo.cor"
outfile <- "out3.dat"
spiCall <- paste("cd", mydir, "&& (" , stime, "&& echo", infile, "&& echo", outfile, " ) | spi_sl_6")
shell(spiCall)
关于r - 如何使用R调用exe程序和输入参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45198319/
我刚刚用 java-swing 为我写了一个桌面时钟,我希望每次登录时该时钟都运行。 为此,我将我的 jar 文件添加到 start 文件夹,我让时钟开始运行。 但我的问题是 - 任务栏中显示的图标允
我正在尝试编写一个程序来检查用户是否上传了新视频。我想让它成为一项后端工作,不断检查用户最近的视频,然后使用我的应用程序向我的用户发送推送。有关于这个问题的任何文档或示例代码吗?我完全不知道从哪里开始
我正在为我的 Raspberry Pi 编写一个程序,该程序由两个主要部分组成: 使用 Spotify-API“Libspotify”搜索音乐并播放音乐的 C 程序。 一个在 apache2 We
我做了一个C++生成命令行并将命令转发给它的程序。目前,我正在将 cmd 控制台的输出发送到一个文件,并在我的 C++ 程序中读取它。但我想让它与管道一起工作。 是否可以从 Windows cmd 行
是否可以使用 C 程序和 malloc 找出处理器的页面大小?而不是使用 sysconf() 调用? 最佳答案 如果你可以#include一些linux内核头文件,你可以在中找到宏PAGE_SIZE
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 8 年前。 Improve this ques
我想实现一个算法: 从 Ruby on Rails 应用程序获取数据库对象作为输入, 对输入执行计算, 根据计算查询 Rails 数据库, 并根据查询生成一组有序结果。 我将用 C(也许是 Objec
我今天的任务是创建一个 Python 脚本(例如 A.py),它可以执行以下操作: 启动 C 程序(例如 CProg)并传递一些参数 启动另一个 Python 脚本(例如 B.py)并传递其他参数 加
我有一个在后台运行的 .NET 程序,需要创建一个可以与该程序通信的 Windows Shell 扩展。起初我以为我会在 .NET 中创建我的 Shell Extension,并使用 IpcServe
Python 程序做前端工作,C 程序做后端工作。它们中的每一个都是一个单独的过程。 Python 进程充当主进程,向 C 进程发送信号和事件。 C 进程生成统计信息、计数器和信息,这些信息被发送回
如何与 shell 脚本共享 C 头文件? shell 脚本通过命名管道与 C 程序通信。让我们假设 C 头文件中定义的枚举 SAMPLE_ONE 由 C 程序写入管道。 shell 脚本从管道中读出
我有一些客户/候选人提示我的程序不能在他们的 Windows 7 64 位版本上运行(已通过屏幕截图确认)。错误很奇怪,例如: in the trial version i am getting a
这个问题在这里已经有了答案: Why SDL defines main macro? (2 个答案) 关闭 7 年前。 我在 Windows 操作系统下使用 QT Creator 的简单程序中使用
我的导师给了我们一个基本的 C shell 来扩展,我目前正在努力让 shell 在用户在命令行中输入“cd [directory]”时更改目录。我已经得到它来停止段错误,但它不会更改目录。谁能告诉我
我以前有过这个工作,但我使用的是指针。 getenv() 不断崩溃,所以我使用 sprintf() 复制了结果。现在我想用 : 删除并只打印第一次出现的地方。请帮忙! #include #inclu
你好,我第一次使用 C primer plus book 学习 C,然后在第 16 章关于 C11 标准的 _Generic 我在 Eclipse c/c++ 中编写了一个程序并构建它产生了 8 个错
我正在尝试从另一个 C 程序执行 python 程序,其中 py 脚本的返回值为 int array[3] 我可以从 python 退出代码中获取这个数组吗?? 编辑:如果问题不清楚,我可以将 pyt
// The countChicken() method should count the number of occurrences of the word chicken (or some oth
我已经通过 ZMQ 使用同一类成功地从 C# 和 C++ 程序传输数据,其中 C++ 类是数据定义,编译器幸运地将字节数组屏蔽到类。 我如何在 C# 和 Node.js 程序之间做同样的事情?我认为他
任何人都可以为我指明有关 makefile 如何工作以及如何使用 eclipse 从头开始基本程序的好教程的方向吗?我正在为 fedora 和 C++ 使用 eclipse 3.4.1 版。提前致
我是一名优秀的程序员,十分优秀!