Obtaining a regression table with texreg in Lyx - lyx

I'm using the packages knitr and texreg in a Lyx document and I've got this problem. When I'm using a float table in Lyx, I've always got this lines before the table in the pdf:
## Version: 1.36.23
## Date: 2017-03-03
## Author: Philip Leifeld (University of Glasgow)
##
## Please cite the JSS article in your publications – see citation("texreg").
How could I get only the table without these lines?

Related

Stata syntax highlighting in Rmarkdown

I am using Bookdown and Rmarkdown to compose a technical book for Stata users. I would like to include Stata highlighting syntax in the chunks of code, but I am not interested in actually executing Stata from Rstudio. I just want the syntax highlighting.
I learned here that it is possible to use highlightjs but I have no idea how to include it in my .Rmd files.
I would like to be able to include something like the following and get it syntax highlighted.
```stata
sysuse auto, clear
reg mpg length
```
I highly appreciate your help.
Thanks.
Now you can highlight your stata code, by using the latest R packages related to knitting.
rmarkdown Ver. 2.10
knitr: Ver. 1.33
bookdown: Ver. 0.22
You may also have to [u]se a Pandoc version not bundled with the RStudio IDE. I use a Pandoc Ver. 2.14.0.3.
---
title: "Untitled"
author: "author"
output:
bookdown::pdf_document2: default
---
- `rmarkdown`: Ver. `r packageVersion("rmarkdown")`
- `knitr`: Ver. `r packageVersion("knitr")`
- `bookdown`: Ver. `r packageVersion("bookdown")`
- (`pandoc`: Ver. `r rmarkdown::pandoc_version()`)
```stata
sysuse auto, clear
reg mpg length
```

Estimating read time for an R Markdown document and printing it possibly below the title

System: Windows 10, RStudio 1.0.153, R 3.4.1
I write blog posts in R Markdown. I would like to use Medium's approach of including an estimated reading time for the blog post just underneath the title, because research has suggested that including reading time in your blog post increases the likelihood that people will read it all. To estimate reading time I would like to use a simplified version of the algorithm used on Medium:
compute the number N of words in the document, preferably excluding the YAML preface and the R code chunks with echo=FALSE, i.e., all the text that my visitors won't see)
compute the number m of imported images and R-generated plots: if counting plots makes the problem too complicated, it's ok to count only imported images. I import each image separately in its own R chunk with the include_graphics function, thus even just counting the number of occurences of the include_graphics keyword would work.
estimated time in minutes is
seconds <- N/200*60+12*m
minutes <- round(seconds/60)
fin <- ifelse(minutes>1, " minutes", " minute")
estimation <- paste0("Estimated reading time: ", minutes, fin)
The code for the estimation should be executed each time the R Markdown doc is knitted, so ideally inside an R chunk in the R Markdown doc itself, or in an external function which is then sourced in an R chunk. This way, the estimation would automatically update as I edit the R Markdown document. How can I do that? For example, given the sample R document below, which has N=106 words and m=2 images, the text
"Estimated reading time: 1 minute"
should be be included in the HTML output, just below the title, author and date.
Sample R Markdown document:
---
title: "Testy test"
author: "anonymous"
date: "`r Sys.Date()`"
output: html_document
---
```{r setup, include=FALSE}
library(knitr)
opts_chunk$set(echo = TRUE)
```
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r load_data, echo=FALSE}
include_graphics("doge.jpg")
```
## Including Plots
You can also embed plots, for example:
```{r pressure, echo=FALSE}
plot(pressure)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.

how do you print xtable using knitr in word document

I am trying to print xtable in using knitr in word document as follows:
library(knitr)
library(xtable)
p1<-xtable(head(iris), include.rownames=FALSE, floating=FALSE)
print(p1)
I get this error, any ideas:
latex table generated in R 3.2.2 by xtable 1.7-4 package % Mon Oct 26 11:17:22 2015
I don't think you can do this with the standard word_document that comes with rmarkdown. xtable only produces output in HTML and LaTeX formats. To render a word document, your table has to be prepared in markdown format (so far as I know).
Some alternative options are to use knitr::kable or the pixiedust package.
If you're comfortable downloading things from GitHub, you may also use devtools::install_github("gforge/Grmd") and then replace output:word_document with output: Grmd::docx_document. Then using print.xtable with type = 'html' will render to an HTML document that can be opened as a docx.

How to build a pdf vignette in R and RStudio

I am new to writing R packages. I'm trying to learn how to make a vignette for my package. I have created a vignettes folder with a file "getting-started.Rmd"
---
title: "WaterML Tutorial"
author: "Jiri Kadlec"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Introduction to the WaterML R package}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
## Quick Start
This simple example shows how to get started with the <my R package>.
To build the vignette I use the command:
devtools::build_vignettes()
Then I run Rcmd.exe INSTALL my_package, and to view my vignette I run:
browseVignettes("my_package")
However I only see the vignettes in the html and source format:
As you see in the screenshot, there's no "pdf" option. How do I configure my .Rmd file to create my vignette in the pdf format?
In your header, you are telling R to output only an html vignette in line:
output: rmarkdown::html_vignette
If you want pdf, try:
output: pdf_document
According to R packages:
Output: this tells rmarkdown which output formatter to use. There are many options that are useful for regular reports (including html, pdf, slideshows, …) but rmarkdown::html_vignette has been specifically designed to work well inside packages. See ?rmarkdown::html_vignette for more details.
So you might have a few small problems using a raw pdf.
At this time, rmarkdown does not have a output: rmarkdown::pdf_vignette option

creating LaTex table from xtable in R

I have a very basic question however I'm stumped.
I am creating a LaTex table in R and I am having trouble with actually outputting the real table.
Here is example code borrowed from:
http://cran.r-project.org/web/packages/xtable/vignettes/xtableGallery.pdf
data(tli)
tli.table <- xtable(tli[1:10,])
print(tli.table,floating=FALSE)
This code just gives me the raw table output:
% latex table generated in R 3.0.3 by xtable 1.7-3 package
% Tue Jul 15 13:23:25 2014
\begin{table}[ht]
\centering
\begin{tabular}{rrlllr}, etc. etc. etc.
How in the world do I actually see the real table that is shown in the above referenced table. The code in that source seems like the above 3 lines produce the table but, for me, it's just producing the raw version.
Forgive the simplicity of this question but I am stumped.

Resources