我对R有点新,并且对我正在编写的程序有疑问。我希望能够用一个while循环(最终使用每个read.table)接收文件(与用户一样多),但它一直在打断我。 这是我到目前为止有:R:虽然循环输入
cat("Please enter the full path for your files, if you have no more files to add enter 'X': ")
fil<-readLines(con="stdin", 1)
cat(fil, "\n")
while (!input=='X' | !input=='x'){
inputfile=input
input<- readline("Please enter the full path for your files, if you have no more files to add enter 'X': ")
}
if(input=='X' | input=='x'){
exit -1
}
当我运行它(从命令行(UNIX))我得到这些结果:
> library("lattice")
>
> cat("Please enter the full path for your files, if you have no more files to add enter 'X': ")
Please enter the full path for your files, if you have no more files to add enter 'X': > fil<-readLines(con="stdin", 1)
x
> cat(fil, "\n")
x
> while (!input=='X' | !input=='x'){
+ inputfile=input
+ input<- readline("Please enter the full path for your files, if you have no more files to add enter 'X': ")
+ }
Error: object 'input' not found
Execution halted
我不太知道如何解决这个问题,但我很确定这可能是一个简单的问题。 有什么建议吗? 谢谢!
@ttmaccer:您应该将其写为答案 – 2012-08-07 14:31:32
您可以尝试使用'choose.files' – James 2012-08-07 14:33:27
@James您是否知道我可以找到如何使用choose.file的示例的地方? – Stephopolis 2012-08-07 14:34:55