I want to save as a .txt file output from my console window (which includes regression summaries) and the lines of code which accompany them. So for example, for an example dataframe:
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
))
... I want to run some summary stats:
summary(df1$col.1)
I have been playing with:
sink("myfile.txt", append=TRUE, split=TRUE)
... but only the...
Min. 1st Qu. Median Mean 3rd Qu. Max.
2.0 3.5 5.6 9.2 7.9 31.2
... is exported. How would I get the command lines as well as the outputs?
Many thanks.