Dinesh Dinesh - 5 months ago 17
R Question

Interactively ask user for filename before saving file

I want to save the my tab delim files manually. I mean that I want user to choose the directory and file name when he wants to save the data. (For an example I have merged individual files into single file and want to save it.)

Usually I use

but in
we define the directory path and file name within that function but I want a function in which user can save file with any name in his desired directory.

Answer Source

Annoyingly the tcltk package doesn't have a function for 'Save As', it only has a file selector for choosing an existing file.

Luckily you can take the DIY approach via some tcl calls:

write.table(yerdata,file = tclvalue(tcl("tk_getSaveFile")))

The tk_choose.files function source could be used as a template to write a nicer interface to tcl("tk_getSaveFile") if needed. Does seem to be a glaring omission in package:tcltk though...

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download