Closed dfsp-spirit closed 5 years ago
The object built by summary_table
is just a character matrix. There is no plot
method for the object and the print
method formats for markdown or LaTeX.
If you want to see the table in RStudio I would recommend working in a R Notebook.
Thanks for your reply. I needed the output as PDF, so I took the LaTeX output and, in a function, added prefix:
\documentclass{article}
\begin{document}
and suffix
\end{document}
Then all you have to do is paste it into Kile and click Tex to PDF.
Another option for you, if you are looking for pdf as the output write a .Rnw file instead of markdown. a simple example is provided in the example directory. RStudio should knit the .Rnw to .pdf with ease. I don't use RStudio in my day-to-day work so my workflow would have a makefile to run
R --vanilla -e "knitr::knit('<filename>.Rnw')"
latexmk --pdf <filename>.tex
That's a great suggestion. If I can do it without rstudio, and without manually starting other GUI applications like Kile, that's of course even better.
有一个比较曲折的办法可以导出结果到csv中:
下面先展示一下原始的summary_table
的结果:
然后再用这个方法倒一倒就行了:
setwd("D:\\test")
write.table(result, file = "summary_table1", sep = ",", quote = FALSE, row.names = F, fileEncoding = "GBK")
result<-read.table(file = 'summary_table1', header = F, sep = "|", dec = '.', as.is = F, na.strings = "NA", skip = 5, strip.white = T, #comment.char = "T")
col.names=c("1", "variable", "mtcars2 (N = 32)", "6 cylinders (N = 7)", "4 cylinders (N = 11)", "8 cylinders (N = 14)", "P-value", "2"))
就是先输出,再以read.table
的方式读入,注意对每一列命名一下就行了
I guess this is a stupid question and I am overlooking something very obvious, but:
I am using an ordinary R script, not an R markdown document. How can I view the table?
E.g., I would like to make it show up in the Plots panel in rstudio, or export a rendered version to a PDF (or other format) file. I am looking for something like:
The
summary_table
functions returns markdown code it seems. Am I supposed to write this into a text file, then run knitr on the text file to render to an output file, then open that in PDF software?