类似于:read.csv(file.choose()) problem in StatET/Eclipse
在以下代码中,系统会提示用户:
但是在第3步中,我在file.choose()中收到错误 “错误:文件选择已取消” 。在RStudio中发生此错误(但是代码在基本R中正常工作)。
# This works
f1 <- file.choose()
# Something happens in here which will cause the error at the end
msg <- "Click YES"
test <- TRUE
while(test == TRUE) {
# user chooses from menu
letter <- menu(letters, graphics=TRUE, title="Select a letter and press OK")
# user inputs a string
str <- winDialogString(message="Press OK", default="xyz")
# user decides if they want to repeat loop
question <- winDialog(type = "yesno", message = msg)
test <- ifelse(question == "YES", TRUE, FALSE)
msg <- "Click NO"
}
# This will result in: "Error in file.choose() : file choice cancelled"
f2 <- file.choose()
我应该做一些特别的事情让它在RStudio中运行吗?
我在Windows 7 Pro x64上使用RStudio 0.98.932
sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252 LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] tools_3.0.2