简体   繁体   中英

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

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?

LGTM:

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM