在R中导出输出和命令行

时间:2015-06-01 11:25:07

标签: r

我想从控制台窗口(包括回归摘要)和伴随它们的代码行保存为.txt文件输出。例如,对于示例数据帧:

df1 <- structure(list(X = structure(1:9, .Label = c("a", "b", "c", "d", 
                                             "e", "f", "g", "h", "i"), class = "factor"), col.1 = c(2.4, 5.6, 
                                                                                                    7.4, 3.5, 31.2, 2, 7.9, 5, 17.8), col.2 = structure(c(1L, 1L, 
                                                                                                                                                          2L, 2L, 2L, 1L, 2L, 2L, 1L), .Label = c("cat", "dog"), class = "factor")), .Names = c("X", 
                                                                                                                                                                                                                                                "col.1", "col.2"), class = "data.frame", row.names = c(NA, -9L
                                                                                                                                                                                                                                                ))

...我想运行一些摘要统计信息:

summary(df1$col.1)

我一直在玩:

sink("myfile.txt", append=TRUE, split=TRUE) 

......但只有......

Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
    2.0     3.5     5.6     9.2     7.9    31.2

...已导出。我如何获得命令行以及输出?

非常感谢。

0 个答案:

没有答案