sweave

Sweave in Rstudio — no plots showing in pdf

大兔子大兔子 提交于 2021-02-17 06:47:08
问题 Sweave/Latex newbie here. I have no problems generating regular functions outputs, but the plots don't show up. Here's a basic example: \documentclass{article} \begin{document} \SweaveOpts{concordance=TRUE} <<chunk1>>= print("Hello World") boxplot(rnorm(100)) @ \end{document} And the corresponding .tex output: \documentclass{article} \usepackage{Sweave} \begin{document} \input{test2-concordance} \begin{Schunk} \begin{Sinput} > print("Hello World") \end{Sinput} \begin{Soutput} [1] "Hello World

Indenting disturbed when adding superscript to rowname of a grouped row using kable in latex

ぃ、小莉子 提交于 2021-02-10 15:07:28
问题 How do I add superscript to name of a particular row of a table created using kable in latex environment (this link gives solution for markdown). I tried following: at2=cbind(1:5,6:10,11:15) rownames(at2)=c("one", "two", "three", "four$^1$", "five") kable(at2,format = "latex",booktabs=T) But this isn't working. For image of result click this EDIT: The first problem is solved with escape = FALSE but now a new problem related to indentation has come up. I am using group_rows which automatically

Indenting disturbed when adding superscript to rowname of a grouped row using kable in latex

房东的猫 提交于 2021-02-10 15:05:11
问题 How do I add superscript to name of a particular row of a table created using kable in latex environment (this link gives solution for markdown). I tried following: at2=cbind(1:5,6:10,11:15) rownames(at2)=c("one", "two", "three", "four$^1$", "five") kable(at2,format = "latex",booktabs=T) But this isn't working. For image of result click this EDIT: The first problem is solved with escape = FALSE but now a new problem related to indentation has come up. I am using group_rows which automatically

Put a part of a text in bold in \sexp with Sweave

僤鯓⒐⒋嵵緔 提交于 2021-01-29 21:40:01
问题 I used a condition to display 2 differents text with Sweave. After that, I display this text. But I would like to bold a part of my first text. <<condition, echo=FALSE>>= if (x > 0) { text <- paste("text 1 start :",paste(variables, collapse = ","), ". text 1 end.") } else { text <- paste("text 2") } @ \Sexpr{text} Here, the actual output in my report.pdf is: text 1 start : var1, var2, var3 text 1 end But I would like : text 1 start : var1, var2, var3 . text 1 end 回答1: You could return your

Put a part of a text in bold in \sexp with Sweave

此生再无相见时 提交于 2021-01-29 19:59:39
问题 I used a condition to display 2 differents text with Sweave. After that, I display this text. But I would like to bold a part of my first text. <<condition, echo=FALSE>>= if (x > 0) { text <- paste("text 1 start :",paste(variables, collapse = ","), ". text 1 end.") } else { text <- paste("text 2") } @ \Sexpr{text} Here, the actual output in my report.pdf is: text 1 start : var1, var2, var3 text 1 end But I would like : text 1 start : var1, var2, var3 . text 1 end 回答1: You could return your

R Sweave (Rnw) won't produce a PDF file - exit code 1

只谈情不闲聊 提交于 2020-12-15 05:16:32
问题 I've recently been learning how to use sweave in R to create PDF files out of Rstudio, and my machine has suddenly stopped being able to create a PDF using sweave. It can still create PDFs in rMarkdown, but it gives the exit code one when it fails to do so in sweave. There are maybe a dozen questions that I've found online that ask similar questions, but none of the answers have helped. I've tried changing the %PATH% in my environment window, I've uninstalled and reinstalled rStudio and

Sweave + RweaveHTML: cat output does not appear in the output

杀马特。学长 韩版系。学妹 提交于 2020-02-04 04:59:12
问题 I have a problem with Sweave + RweaveHTML I want the output of cat ends to up in the html file being generated. I have a case in which it does not and I can't figure out why :( test = function() { #bla bla; cat("Result is...") } And then in the Rnw file I tried all of these: <<echo=FALSE, results=html, include=TRUE>>= test() @ <<results=html, include=TRUE>>= test() @ <<results=html>>= test() @ <<>>= test() @ But I don't get the cat output in the resulting HTML file. I'm pretty sure this is

How do I insert a line break in an xtable caption?

≯℡__Kan透↙ 提交于 2020-02-02 13:37:00
问题 I'm sure it's a simple solution but Ive been searching all day trying to solve this. All I want to do is split an xtable caption over 2 lines. I've tried \n and caption.width to no avail. \documentclass{article} \usepackage{caption} \begin{document} <<makedata,echo=TRUE,results='asis'>>= df <- matrix(round(rnorm(9, 20, 10)), 3, 3) colnames(df) <- c("Column1","Column2","Column3") require(xtable) print (xtable(df, caption="Title1\nTitle2"),caption.placement="top") @ \end{document} 回答1: I think

Extending Stargazer

爱⌒轻易说出口 提交于 2020-02-01 04:21:06
问题 I've long used apsrtable to quickly create model comparison tables, but I find it somewhat unattractive and clunky, so my dissertation tables were hand-coded tables with \Sexpr expressions. I was excited to find stargazer , but disappointed that some models I use aren't supported. With apsrtable you can fairly easily extend a model by updating the apsrtableSummary and ModelInfo methods (as in this question/answer). I've been looking (but haven't found) for a similar method to extend stargazer

LaTeX math expression in knitr kable (Sweave)

旧巷老猫 提交于 2020-01-13 07:53:09
问题 Is it possible and how to use a LaTeX math expression in a knitr/Sweave report with kable ? In the example below, $x^2$ is rendered "as is". With xtable , for the example below, I would use the option sanitize.colnames.function = function(x) x of print.xtable . Is there such an option for kable ? \documentclass{article} \usepackage{booktabs} \begin{document} <<>>= library(knitr) dat <- mtcars[1:5,1:5] options(knitr.table.format = "latex") @ <<results='asis'>>= names(dat)[1] <- "$x^2$" kable