How can I Insert images into .rnw document - r

I work in R and deliver PDF file with Sweave, sweave(.rnw document). I need to put into my text a JPEG image. I didn't find any function on the web and have no ideas about how I could do that.

You include it just like you include an image in any other LaTeX document:
http://amath.colorado.edu/documentation/LaTeX/reference/figures.html#pdf
\includegraphics{myimage.jpg}
Put it in a LaTeX block not an R code block. As the link points out, you'll need to compile with pdflatex.

Related

produce standalone html for chunks of an Rmarkdown document

I am searching for a way to produce a standalone HTML document from a chunk in Rmarkdown.
My example is this:
I have an Rmarkdown document for my analysis.
In one chunk of code, I produce interactive plotly plots that are quit long to load when I open the HTML.
I am looking for an option that would create another HTML document for this particular chunk and put a link to it in its place in the master HTML document.
I am sure I could manage to do something like that with a bit of tweaking with another script, but I would like to know if there is not a simpler option first.
Thanks
Yes, you can nest documents using knitr child documents. Put the chunk you want to isolate in its own Rmd (say, child.Rmd), then use this syntax to insert it in the master document:
```{r child='child.Rmd'}
```

How can I insert pdf images in an R presentation?

I am writing an R presentation in an .Rpres file. I published my presentation on Rpubs here: http://rpubs.com/cr517/presentationGurdon
I have images stored in PDF files. I am trying to include them in my presentation, unsuccesfully. I am using this command to include the images:
![Chromosome sizes](input/images/bar/nbOfGenesPerChrom.pdf)
the same as for .jpg. This command does not result in the display of the image. I have tried to follow these answers but could not make it work:
R markdown: can I insert a pdf to the r markdown file as an image?
Add pdf file in Rmarkdown file
If somebody could help me, that would be much appreciated. That would spare me the re-run of my code exporting images in .jpg format.
Thank you so much.

Source or input or include Rmd file in a Rnw document

I am trying to write my paper and using Elsevier document class as a Rnw document. I also tried to use rticle package which I find little difficult to customise. Is it possible to include Rmd file in my Rnw document so that I can use the Rnw frame and also use my Rmd chapters for other purposes like comple it to HTML.
As suggested by r2evans, I want to post what I have found as an answer to my own question. It is not a direct answer to my question but I will be following this for now. Instead of using Rnw file, Rmd file can use tex template. The process is described in this site.

Enabling R Markdown syntax highlighting in TextWrangler/BBEdit

I would like to enable syntax highlighting for R Markdown (.Rmd) highlighting in TextWrangler. I managed to get syntax highlighting for .R files using this R.plist file (direct link to file). R Markdown has similar highlighting, so I have that file as a starting point, as I cannot find a similar .plist file for .Rmd files.
The issue I am having is that in RMarkdown, the code is between a set of ``` (three backticks) and the text (which is what I'd like to demarcate as comments) are the remainder of the file.
I would like to tell TextWrangler to only highlight what it sees between a set of ``` - currently, it highlights the entire file (including my text sections).
I thought editing the values for keys
<key>Open Block Comments</key>
<string></string>
<key>Close Block Comments</key>
<string>```</string>
would be a workaround, but it doesn't seem to help.
Edit, here is the Rmd syntax:
here is some text that is whatever I want.
```
in here between the backticks is some code
```
here is some more exposition
The code I'd like to highlight with R syntax is between backticks, whereas the text I'd like to display as a comment/without highlighting (whichever is easiest) is not demarcated.

knitr html to Word docx using pandoc

I have been saving some example R markdown html output to Word using pandoc. I actually only do this so I can add some page breaks for easier printing:
system("pandoc -s Exercise1.html -o Exercise1.docx")
Although the output is acceptable I was wondering if there is a way to keep the original syntax highlighting of the R chunks (just as they are in the original knit HTML document)?
Also, I seem to be loosing all images in the conversion process and have to stick them into Word by hand. Is that normal?
Using the rmarkdown package (baked into RStudio Version 0.98.682, the current preview release) it's very simple to convert Rmd to docx, and code highlighting is included in the docx file.
You just need to include this at the top of your markdown text:
---
title: "Untitled" # obviously you can change this
output: word_document # specifies docx output
---
However, it seems that page breaks are still not supported in this conversion.
Why not convert the markdown directly to Word format?
Anyway, Pandoc does not support syntax highlighting in Word: "Currently, the only output formats that uses this information are HTML and LaTeX."
About the images: the Word file would definitely include those if you'd convert the markdown to Word directly. I am not sure about the HTML source, but I suppose you might have a path issue.

Resources