Creating a file with write.table and file.choose on Mac

1k views Asked by At

I am a PC user and have used the write.table (and write.csv) extensively. I am teaching students how to use R, but some of them use a Mac.

On a PC, the following code:

write.table(mydata, file.choose(), row.names=F, col.names=T)

opens up a browser window, allowing the user to specify the folder where to save the new file, and specify the file name and extension. (Strangely enough, the user is then prompted to click the button "Open" to create a file.)

On a Mac however, it appears there is no way of specifying the name and extension of the file being created, once the window opens. In other words, there does not seem to be a way to actually create a file. Am I missing something?

Is the solution simply to replace the "file.choose()" with the full path to the new file?

1

There are 1 answers

0
hrbrmstr On BEST ANSWER

LGTM:

enter image description here

enter image description here

enter image description here

Having said that, if your student is using RStudio then you would normally need to go to their github repo and file an issue but I've already done that https://github.com/rstudio/rstudio/issues/3903. They seem to intercept the call and pass it to Qt which is not honoring it (it's not a macOS issue but a Qt issue).