knitr

Blogging with jekyll, rmarkdown and github: how to display images

时间秒杀一切 提交于 2019-12-10 13:58:26
问题 I try to do a blog using the trio jekyll, rmarkdown and github (as here: http://yihui.name/knitr-jekyll/) I have all my .Rmd in _source, and I have this issue that sometimes the plots are knit in base 64 images and sometimes saved in a figure folder. First question, why? Second question: when my plot are saved as images, the path in the html appear to be figure/source/. Knowing that the destination folder is /blog/ (my baseurl in _config.yml), to make it work, it should be blog/figure/source.

How can I include hyperlinks in a table within an Sweave document?

若如初见. 提交于 2019-12-10 13:33:15
问题 I have a data frame containing hyperlinks that I would like to present as clickable links using Sweave . I know about xtable , but am not sure how to use it to treat the contents of a data frame as LaTeX commands. 回答1: One strategy is to use the sanitize.text.function from the print function in xtable . Setting sanitize.text.function = function(x){x} causes print simply to echo the contents of the data frame for later interpretation by LaTeX: \documentclass{article} \usepackage{hyperref}

How to suppress all messages in knitr/ Rmarkdown?

前提是你 提交于 2019-12-10 13:32:31
问题 I have used dplyr for some of the analyses and for a particular code it takes about 30 seconds to complete the operation. In the resulting HTML I get a very long output of something like this (reproducing last few lines): |================================================ |100% ~0 s remaining |================================================ |100% ~0 s remaining Completed after 35 s I don't want this to show in the output. How can I suppress this? Is there anythink in the global chunk options

RMarkdown utf-8 error on mutliple operating systems

爱⌒轻易说出口 提交于 2019-12-10 13:22:54
问题 We have a problem using RMarkdown on multiple operating systems. Initially, an .Rmd file is created on a Linux system (Ubuntu 12.04 LTS) and then pushed to a GitHub repo. It can be compiled ("knitted") without problems on this system. It is then pulled on a Windows 7 machine with RStudio installed. There, when trying to compile, the following error shows up: Error in yaml::yaml.load(front_matter) : Reader error: invalid leading UTF-8 octet: #FC at 66 Calls: <Anonymous> -> parse_yaml_front

knitr installation in Lyx

拜拜、爱过 提交于 2019-12-10 13:18:42
问题 I was trying to install Knitr package in Lyx but I encountered the following error. "The module knitr requires a package that is not available in your Latex installation or a converter that you have not installed. Latex output may not be possible. Package missing Knitr>latex." I would greatly appreciate if you could please help me to fix this problem. I checked the Lyx module but couldn't figure out exactly what to do. I am a new user to Lyx and Knitr. Thank you in advance 回答1: That is often

Respecting global options in knitr

自闭症网瘾萝莉.ら 提交于 2019-12-10 13:12:10
问题 I am having trouble with setting global options in my R Markdown documents. A simple example follows. In this case I've attempted to set global.par = TRUE . The expectation is that any par() specifications I make in one chuck are carried into subsequent chunks. However, this is not happening. ```{r package_options, include=FALSE} knitr::opts_knit$set(global.par = TRUE) ``` ```{r} lambda <- 0.2; n <- 1000 exp <- rexp(n, lambda) par(cex = 0.7) hist(exp) ``` ```{r} lambda <- 0.02; n <- 1000 exp

Change color of error messages in RMarkdown code output (HTML, PDF)

巧了我就是萌 提交于 2019-12-10 12:51:42
问题 Is there a way to automatically make text color of errors red in R Markdown without manually editing the HTML later. --- title: "" --- #### Example 1 ```{r e1, error = TRUE} 2 + "A" ``` #### Example 2 ```{r e2, error = TRUE} 2 + 2 ``` In the above code, output of Example 1 would have to be red. Currently, I edit the generated HTML (add style="color:red;" to the appropriate tag) but I am wondering if there is an automatic way. Assume that it is not known before knitting whether the code will

tkplot in latex via knitr and igraph

限于喜欢 提交于 2019-12-10 12:43:31
问题 This may be a wild strange dream. I dreampt that I could put a tkplot from igraph inside a latex document via knitr . I know Yihui is know for animation stuff so I thought maybe this is possible. A google search didn't show what I was after so here's a non working attempt: \documentclass[a4paper]{scrartcl} \begin{document} <<setup, include=FALSE, cache=FALSE>>= library(igraph) @ <<network>>= edges <- structure(c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "A", "B", "C", "D", "E", "F",

Stargazer options: resizebox and label

社会主义新天地 提交于 2019-12-10 11:14:48
问题 Is it possible to incorporate resizebox into stargazer in R? I'm trying to create a table that is too wide to fit, even on landscape perspective. I manually added resizebox{\textwidth}{!} { \begin{tabular} \end{tabular} } to the .tex file, and I like how it looks. However, I'd like for my .Rnw file to be complete, so that I can generate pdf perfectly without additional changes to the .tex file. On a related note, stargazer causes pdflatex to output multiple warnings due to it including \label

How to add a watermark image on rmarkdown?

不想你离开。 提交于 2019-12-10 11:08:57
问题 I'm searching and trying to add a image as watermark to rmarkdown pdf, I'm using the render function to generate the PDFs, and saw the \usepackage{draftwatermark} and this question: Watermark in rmarkdown But they don't help me in adding a image as watermark. --EDIT-- I achieved what I wanted putting this to the header of .Rmd: header-includes: - \usepackage{eso-pic,graphicx,transparent} And placing this in the start of file (before the rest of .Rmd): \AddToShipoutPictureFG{ \put(0,0){%