如何使用tcltk将数据框保存为CSV到用户选择的位置 [英] How to save a data frame as CSV to a user selected location using tcltk

查看:94
本文介绍了如何使用tcltk将数据框保存为CSV到用户选择的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为 Fail 的数据框。

I have a data frame called, Fail.

我想在用户选择的位置将失败另存为CSV。下面是我发现的一些示例代码,但我不知道如何将 Fail 加入其中。

I would like to save Fail as a CSV in a location that the user selects. Below is some example code that I found, but I don't know how to incorporate Fail into it.

require(tcltk)
fileName <- tclvalue(tkgetSaveFile())
if (!nchar(fileName)) {
    tkmessageBox(message = "No file was selected!")
} else {
    tkmessageBox(message = paste("The file selected was", fileName))
}


推荐答案

查看 write.csv write.table 函数。您只需提供用户选择文件参数的文件名,并将数据帧提供给 x 参数:

Take a look at the write.csv or the write.table functions. You just have to supply the file name the user selects to the file parameter, and the dataframe to the x parameter:

write.csv(file=fileName, x=Fail)

这篇关于如何使用tcltk将数据框保存为CSV到用户选择的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆