r - 如何在 r 中创建具有输入/输出的函数?
问题描述
我正在考虑用户通过输入输入的函数,如下所示:
cat("check if the directory is the same of the file")
input <- readline(prompt="Enter with file name in form >file.txt<: ")
output<-readline(prompt="Enter with file output in form >file.dat<: ")
然后,在用户输入 .txt 文件名后,计算向量“sum”,顺便说一句:
column <- read.table(input, header=F)
sum = column * 2
最后生成txt文件输出:
write.table(sum, file=output, row.names=FALSE, col.names=FALSE)
它可以工作,但我不知道如何在一个函数中转换所有这些。
解决方案
推荐阅读
- android - android build system根据包名获取源码路径
- flutter-test - 如何在小部件测试中使用 get_it(flutter 依赖注入)?
- jmeter - 在使用 JMeter 进行数据摄取测试期间,我应该采用什么功能/性能测试方法?
- asp.net-core - 获取应用程序用户创建的属于宠物的数据
- reactjs - 使用 React 钩子表单进行表单验证
- netty - ChannelOutboundInvoker.flush() 是同步/阻塞调用吗?
- python - 使用 SWIG 的 CPP 到 Python 失败并出现“错误 LNK2001:未解析的外部符号”
- clojurescript - 我用goog.structs.LinkedMap实现cljs.core/IFn协议,但是不能用函数形式调用LinkedMap的实例
- c# - 将指向音频缓冲区的指针从 C# 传递到 C++ ATL DLL 时出现问题
- javascript - Javascrip 遍历 for 循环 - 逻辑