knitr

Error when knitr has to download a zip file

穿精又带淫゛_ 提交于 2019-12-07 04:06:30
问题 Due to clash with the network security system the only way I cand download a data file from the internet to an area in the network where it can be used in R it is by downloading it through R itself. When I run the script in RStudio it works fine. When I try to knit the script I will get either the message Unsupported URL or I will get Error in file(file, "rt") : cannot open the connection Calls: <Anonymous> ... withVisible -> eval -> eval -> read.csv -> read.table -> file Execution halted

HTML outputs are different between using knitr in Rstudio & knit2html in command line

旧城冷巷雨未停 提交于 2019-12-07 02:26:58
问题 I am trying to generate html documents from R markdown files using knitr. When I use the knit html button in R studio it works fine and it gets me the desired output. However when I use knit2html() in the commandline, the formatting of the output html is different (less prettier) than that obtained from rstudio. Can you tell me what are the exact options and functions that are being used when I press the knit html button? I wanted to include images, but apparently my "reputation" is too low..

Insert date in filename while knitting document using RStudio Knit button

冷暖自知 提交于 2019-12-07 01:48:41
问题 I would like to include the current date in the output filename when knitting a document using RStudio's knit button. I can somehow change the options of the markdown rendering, but I don't know how. Could anyone point me into the right direction? 回答1: You can do this in the console: library(knitr) knit("test.Rmd") knit2html("test.md", output=paste0("test",Sys.Date(),".html")) # Sys.Date() is a string with the current date Alternate, better version: rmarkdown::render("test.Rmd",output_file

Source code from Rmd file within another Rmd

泪湿孤枕 提交于 2019-12-07 01:38:38
问题 I'm attempting to make my code more modular: data loading and cleaning in one script, analysis in another, etc. If I were using R scripts, this would be a simple matter of calling source on data_setup.R inside analysis.R , but I'd like to document the decisions I'm making in an Rmarkdown document for both data setup and analysis. So I'm trying to write some sort of source_rmd function that will allow me to source the code from data_setup.Rmd into analysis.Rmd . What I've tried so far: The

Extract html dependencies for .Rmd file (containing htmlwidgets)

浪尽此生 提交于 2019-12-07 01:32:22
问题 Question How could I create a function which would take a .Rmd file (containing htmlwidgets code) as its input, and output a html file containing its JavaScript/CSS dependencies? Specifically, the tempfile rmarkdown generates for pandoc's --include-in-header argument, when rendering to html. Details Example -- myfile.Rmd: This is some text ```{r} library(dygraphs) dygraph(nhtemp, main = "New Haven Temperatures") ``` Running rmarkdown::render('myfile.Rmd') passes a tempfile to the --include-in

Change default alignment in pander (pandoc.table)

旧时模样 提交于 2019-12-07 00:57:29
问题 I am currently switching to pander for most of my knitr-markdown formatting, because it provides such great pandoc support. One of the things I am not so happy with is the default center-alignment. Marketing people may love it, but for technical reports it is an horror. The best choice used by Hmisc is to use left alignment for texts and dates by default, and right alignment for number of all type. Is there a simple way to get this globally set in pander ? library(pander) pander(data.frame(

Longtable in a knitr (PDF) document: using xtable (or kable)

纵饮孤独 提交于 2019-12-07 00:23:03
问题 I am new to knitr and I have had some very basic latex knowledge in the past, so I googled already hoping to find a solution that was already posted somewhere. However, I was not able to solve my problem. I am hoping someone will be kind enough to provide help. I have a data frame of 14 columns and many rows, let's say 60. Using the data I need to produce a PDF report in landscape layout and present this data frame as a table there. The closest solution I found is here at tex.stackexchange

Set code background colour in R markdown to PDF

主宰稳场 提交于 2019-12-07 00:19:50
问题 When an Rnw file is converted to PDF with RStudio and knitr , the code blocks have a pleasant grey background colour (like they do here at SO). When I convert a md file to PDF , the background colour is white and I can't seem to change it. The knitr code decoration option background is only for LaTeX and has no effect in md . How can I set a background colour for code blocks in the PDF I get from my md file? I see in some related questions that editing the markdown.css file might be relevant,

Use rmarkdown/knitr to hold all code until the end

℡╲_俬逩灬. 提交于 2019-12-07 00:13:58
问题 I'd like to be able to generate a document using knitr/rmarkdown that keeps all the output together, but leaves the code until the end, ideally as a referenced footnote of sorts (i.e. the code for each figure or output can be looked up in the appendix using a footnote). Is this possible? 回答1: If I understand correctly what you mean. You can add a label to your original code chunk and then refer to it using a ref.label property and prevent its further execution with eval=FALSE . For instance:

knitr::kable is there a way to reduce the font size?

感情迁移 提交于 2019-12-06 23:21:14
问题 I am using this code chunk ```{r, echo = FALSE} knitr::kable(df) ``` However I would like to reduce the size of all font inside this table so that the output looks nicer. Is there a way to do that with kable or is there another package which supports it? 回答1: You can also try library(kableExtra) . It has a lot of options to customise the table. Specifically, for font size: https://haozhu233.github.io/kableExtra/awesome_table_in_html.html#font_size df %>% kable("html") %>% kable_styling(font