knitr

Invalidate a chunk's cache when uncached chunk changes

孤人 提交于 2019-12-19 07:25:07
问题 I have a question regarding the knitr chunk option "dependson". As far as I understood the manual this option should be used to specify which other cached chunks a cached chunk depends on. But is there a way to invalidate a chunk's cache when an uncached chunk changes? Here's a minimal example: File knitrtest.Rnw : \documentclass{article} \begin{document} <<>>= library(knitr) read_chunk("chunks.R") @ <<not_cached>>= @ <<cached, cache=TRUE, dependson="not_cached">>= @ \end{document} File

How to make vertical scrollbar appear in RMarkdown code chunks (html view)

时间秒杀一切 提交于 2019-12-19 06:25:21
问题 I've found many examples outlining how to add horizontal scrollbars to R Markdown HTML output, including this specific example here. However, none that describe how to add vertical scrollbars. Again borrowing from the linked example, but transposing a wide matrix to a "tall" matrix, I'd like to scroll vertically through the matrix in my ioslide presentation. --- title: "Vertical needs" author: "Hyped" date: "December 13, 2016" output: ioslides_presentation --- ```{r setup, include=FALSE}

How can I print to the console when using knitr?

随声附和 提交于 2019-12-19 05:33:49
问题 I am trying to print to the console (or the output window) for debugging purposes. For example: \documentclass{article} \begin{document} <<foo>>= print(getwd()) message(getwd()) message("ERROR:") cat(getwd(), file=stderr()) not_a_command() # Does not throw an error? stop("Why doesn't this throw an error?") @ \end{document} I get the results in the output PDF, but my problem is I have a script that is not completing (so there is no output PDF to check), and I'm trying to understand why. There

knitr - error when importing python module

爱⌒轻易说出口 提交于 2019-12-19 05:15:06
问题 I am having trouble when running the python engine in knitr. I can import some modules but not others. For example I can import numpy but not pandas. {r, engine='python'} import pandas I get the error. Quitting from lines 50-51 (prepayment.Rmd) Error in (knit_engines$get(options$engine))(options) : Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named pandas Calls: <Anonymous> ... process_group.block -> call_block -> block_exec -> in_dir ->

How to include multiple plot3d in markdown (knitr) under a loop

半世苍凉 提交于 2019-12-19 04:03:29
问题 I am plotting a 3d graph using plot3d {rgl} in a loop. knitr rgl hooks works fine for single 3d graph but when used in a loop, markdown file doesn't include 3d graphs. 回答1: One way you can do it is to use mfrow3d() to put multiple "subscenes" in a single "scene", then use the rglwidget() command to show the scene in your html. See more information here. Below is a heavily modified version of the script from Yihui's answer: --- output: html_document --- You will need to install the rglwidget

how do you change colors of certain cells in xtable markdown?

和自甴很熟 提交于 2019-12-19 03:12:37
问题 I have a data frame called j: dput(j) structure(list(Trans = c(89.8, 3337, NA, 97.55, NA, 3558.7, NA, 4290.6, NA, 65.95, 94.55, 3495.9), `%CPU` = c(6.938, 79.853, 1.875, 4.87, 1.46, 37.885, 1.63, 64.576, 1.165, 3.425, 5.67, 33.856), `%Heap Used` = c(9.9, 76.95, 3.77, 9.8, 6.73, 59.23, 3.94, 67.38, 3.73, 9.13, 9.57, 62.11), `Heap Usage/MB` = c(263.884, 1942.246, 99.104, 257.717, 178.951, 1657.447, 99.933, 2137.134, 96.687, 242.024, 256.302, 1646.117)), .Names = c("Trans", "%CPU", "%Heap Used",

Error: pandoc document conversion failed with error 43 Windows 7 R studio

梦想的初衷 提交于 2019-12-18 22:20:14
问题 I have search the answers in the forum, but they dont seem to work. I am knitting a pdf document in Rstudio using the knitr package. I am using Windows 7 and Rstudio. pandoc.exe: Error producing PDF from TeX source Error: pandoc document conversion failed with error 43 In addition: Warning message: running command '"C:/Program Files/RStudio/bin/pandoc/pandoc" PA1_template.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures -

knitr displaying digits of an integer without scientific notation

只愿长相守 提交于 2019-12-18 19:04:44
问题 when displaying a number with inline-code with more than four digits like `r 21645` the result in a knitted html-file is this: 2.164510^{4} (in reality inside the inline-hook there is a calculation going on which results in 21645). Even though I just want it to print the number, like so: 21645 . I can easily fix this for one instance wrapping it inside as.integer or format or print , but how do I set an option for the whole knitr-document so that it prints whole integers as such (all I need

Looping through code in knitr and rmarkdown

。_饼干妹妹 提交于 2019-12-18 18:20:35
问题 I have been putting together reports using Knitr and rmarkdown. I love being able to output my R code in a reproducible R format, however I am continuously running into a limitation and am wondering who has tackled this before. I need to loop through say two pages with various content and knitr settings for each collection of data in a list. Once the code for those two pages is written I would like to fill in i for each collection in a list (1, 2, 3, 4, 5, etc). For the example below I have

How to extract the content of SQL-Files using R?

流过昼夜 提交于 2019-12-18 17:29:21
问题 I have of folder/directory of one of my colleagues full of sql statements. The folder is updated by him daily as well. I would like to document these sql statements for futures colleagues. However, I'm looking for a way to "automate" that process. I thought about to use crontab once a week and run a R-Markdown file which automatically update the existing R-Markdown file. My approach is as follows: path = "c:/SQL_files/" out.file<-"" file.names <- dir(path, pattern =".sql") # here I changed `