when trying to knit my Rmd to output it as pdf document, some of the outputs get out of bounds
example of the output that gets out of bounds:
The YAML and settings are this:
.
Also when I "knit on save", the rstudio doesn't stop the process untill i give up waiting, idk if it's because it is trying to knit a big pdf(140 pages), but when i press stop in the Render it aborts and somehow the document shows up in my files.
Although I don't show it, i have the knitr packages installed. I've tried many forms of output, the only YAML format that i can generate a pdf with is the one from the picture. Idk if there is something that could prevent the outputs to go out of bounds. Help is appreciated
Related
I'm currently doing an R Markdown File of an analysis I recently finished using R. With that, whenever I add details, I click Knit to ensure everything I added goes well on the HTML knit file.
I noticed that when I used ggplot on my R Markdown file, the file doesn't knit anymore and it says:
Error while opening file - No Such File or directory.
But when I deleted the ggplot command, it gets knitted again.
But this time, without the visualization, it gets knitted again.
UPDATE: I see this error message on the console tab everytime I use ggplot on my .rmd file.
So with that, I call on install.packages("ggplot2") & library("ggplot2") on my .rmd file. However, I get this error instead.
How will I be able to retain the ggplot command and at the same time be able to knit the file? As an added reference, the ggplot command executes on the .rmd file, it just doesn't knit. Can someone help me please?
RStudio renders mynotebook.nb.html file every time R Markdown document mynotebook.Rmd is saved. This process does not involve running code in chunks, so it is much faster than knitting a notebook into mynotebook.html. However, for large .Rmd documents, saving nb.html files can take a long time, and, unfortunately, it is required to wait for it to finish before one can start using the notebook again and run code in chunks.
Is there a way to configure RStudio to not to create nb.html files on save of an R Markdown document?
I've found out you can delete relevant output entry from the top section of your file. In my case it looks like:
---
title: "Document"
output:
html_notebook: default
---
Which causes creation of .nb.html on every save. If you remove the output tag, file is no longer created automatically. You can still knit to any output file from the Knit menu on the top (or press Ctrl+Shift+K for default. This will run all the chunks again, which may take a while.
You may want to consult this guide book for more information on how YAML tags work. I'm just beginning with them!
Another reason (and solution) might be, that you clicked incidentally on the "Knit on Save" button located just under the Save-to-Disk-Symbol in RStudio. This was in my case the problem. Usually you should be able to save a rmd-file without triggering the knitting process.
So - given this scenario - just uncheck the "Knit on Save" button.
I have an rsweave file that I run almost twice a week. Last time I used it a change a couple of things and when I run it to compile to pdf I got the following errors:
The pdf compiles complitly, and the only thing I notice that the error did is that the the pdf output has a extra page (the first one) all blank. I don't know how to make a reproducible example of the errors because I don't know whats the cause of it. But any way I just want to know generally how to debug a rsweave file when getting latex error like the ones in the picture
You don't say how you are running Sweave, but that looks like RStudio. To debug something like this, just run Sweave explicitly in the R console, e.g. if your input file is source.Rnw, run
Sweave('source.Rnw')
This will produce source.tex. Open that file in a text editor and look at the start of it. You will see that \Schunk is used on line 27, but \begin{document} doesn't occur until sometime later.
My guess is that you added some text or a code chunk to the header. All text belongs after \begin{document}.
Edited to add: It turns out from the comments below that you were using print(...) in a code chunk before \begin{document}. In Sweave, print output goes into the document. If you want a message to show up in the console log but not the document, use message("some text"). You'll also need to suppress the echoing of the command if you want to do this in the document header. For example,
<<echo=FALSE,results=hide>>=
message("Started at ", Sys.time())
#
will result in something like this in your console log:
1 : keep.source term hide (Untitled.Rnw:6)
Started at 2017-09-27 08:28:33
and nothing in the document.
I want to use spin() function for my R script to produce rmarkdown .Rmd file. Instead, RStudio returns .md file. This happens in RStudio Preview version 1.1.331.
My R file is from https://github.com/yihui/knitr/blob/master/inst/examples/knitr-spin.R. I downloaded it and put inside my working dir. I then typed spin("test.R", format = "Rmd") in the Console pane.
When I clicked enter, in the console, it showed processing file:knitr-spin.Rmd then output file: knitr-spin.md. Then knitr-spin.html and knitr-spin.mdwere visible, but there was no knitr-spin.Rmd in the working folder.
For the next try,
I clicked the Compile Report button
I chose MS Word outputs
Unfortunately, I still received a folder and an html file and no .Rmd file. Not even .md file was created.
The last time I used spin() or Compile Report was inside RStudio 1.0.153 and it worked nicely and I got .Rmd files, html and MS Word files.
What have I done wrong or I missed?
This should work:
spin("file.R", knit = FALSE) # convert to Rmd only
According to the documentation, argument spin appears to be what you're after:
precious
logical: whether intermediate files (e.g., .Rmd files when format is "Rmd")
should be preserved; default FALSE if knit == TRUE and input is a file
Next to the Knit button there's a sprocket. Click on the Advanced tab and check "Keep markdown source file".
I'm trying to write a Bash script in Ubuntu 10.04 that opens a Python file which exports a CSV, and then runs the following Rscript with the goal of exporting a HTML with plots from Dashboard.Rmd:
require(knitr)
setwd('/home/sensors/Desktop/')
knit2html('Dashboard.Rmd')
browseURL('Dashboard.html')
Dashboard.Rmd is an R markdown that calls read.csv on the csv from the first step, makes a data frame and creates plots, but that part's working fine. According to this, I figure that Rscript should replicate the action of pressing "Knit HTML" in R Studio. However, the html it creates is identical to the last time Knit HTML was pressed; i.e. even if the CSV is different, the html doesn't reflect the change.
I also tried using a separate line for knit and markdownToHTML with the same effect. It seems like it doesn't source the code from the Rmd when performing knit. It does update the html properly when I enter the commands from that Rscript into the console of R Studio with Dashboard.Rmd open. However I'm not sure how to translate that into a Bash script. I also tried knit2html with envir=new.env(), envir=R_GlobalEnv, and envir=parent.frame() with no luck. Any help would be appreciated!
So it turns out that this was an artifact of cache=TRUE -- the HTML file was not changed because everything was cached.