Save file interactively?

Using tk_choose.filesor file.choose, I can select a file interactively. Is there a similar function in which I can let the user interactively decide where to save the output of the write.table?

+3
source share
4 answers

On Windows 7 and working through RGUI, I can specify something like:

write.table(x = iris, file = file.choose())

which opens the windows explorer dialog. Then I can go to any existing file, create a new file by right-clicking or simply typing the name of a new file, where it will ask you to create a new file.

I suppose this may be platform independent ... can other users with the appropriate OS check?

+3

val <- tkgetSaveFile(initialfile="", title="Save a file...")
f <- tclvalue(val)
if(f != "") ...
+2

, , tcltk2 tcltk:

library(tcltk2)
filename <- tclvalue(tkgetSaveFile())
if (!nchar(filename)) {
  tkmessageBox(message = "No file was selected!")
} else {
  tkmessageBox(message = paste("The file selected was", filename))
}
+1
source

@Chase - this works on OS X (Eclipse and StatET). At least I tried to write the data.frame (df) file as a CSV file:

write.csv(x = df, file = file.choose())
0
source

All Articles