In RStudio display Images inline in Rmarkdown files? - r

I am new in R and getting output(images/ interactive plots) displayed by some packages in viewer pane. I would rather like them to be displayed in the ramrkdown notebook.
Here is an example, using magick::image_read() which displays image in viewer pane and not inline:
Reference link where a knitted document has produced images within the notebook using same package as I have used: https://cran.r-project.org/web/packages/magick/vignettes/intro.html
Below are the settings I am using:
Have asked similar question on keras package earlier How to make plots appear in Rmarkdown file instead of viewer pane when working with keras in Rstudio?
This is happening with some of the packages, how do I make these images/plots appear inline ?

Related

Exporting Formattable

I made a table with the package formattable and I want to export in an image form so that I can put it in my research paper but I am not able to get the whole document out from the R studio export option.
I used this code but instead it made a web page.
I could not submit the code I tried because of the issues I have been getting.
if the table get generated in the viewer pane, you can export it to a .pdf or a .png with Rstudio and you can control the ratio.

custom ppt templated changes doesn't render rmarkdown

I am attempting to render a powerpoint presentation from rmarkdown.
I downloaded this powerpoint template and associated files from sol-eng and am able to generate the powerpoint as is.
However, if I open the template and do
view -> slide master
and adjust any of the slide master (i.e. change the background color)
close slide master -> save
I get the error "The file may be damaged or it may have been created in a pre-release version of PowerPoint." when I attempt to render the powerpoint.
I am unclear why using the template as is vs changing the background would generate an error in making the powerpoint presentation.
Any suggestions would be helpful:)
it might be that R writes binary differently than Powerpoint. Is it possible to create a ioslide or beamer slide file with the original powerpoint file instead? If you do IOSlides or beamer, the view with only need a web browser and could be a more flexible file for presentation
I used a different computer/version of powerpoint; adjusted the master slide and now it works - still unsure why I couldn't adjust with my version of powerpoint so I am guessing some versioning issue.

Figures or plots with accompanying thumbnails, like in RStudio

When I create plots within a single chunk of an R-Studio markdown file, they appear in a nice array with clickable thumbnails:
However, when I publish as an HTML file, these figures are simply displayed vertically, one after the other. Is there any way to achieve the way that it originally looks in RStudio?
Unfortunately there's no way to output what RStudio shows you, but you can do this and a lot of other HTML formatting yourself using the knitrBootstrap package.
Check out the end of this example for a clickable-thumbnail example.

size of figure in slides created by Knitr

I want to add a figure in slides by creating the beamer PDF in Rstudio with Knitr from .Rmd file, how can I control the size of the figure for figure I added with the following command?
![](plot/myfigure.png)

MathJax script issue after customizing rstudio.markdownToHTML()

With knit2html() from the knitr package, I can generate html pages that contain latex equations and R code. But on my system equations are not rendered when using RStudio's "knit html" button.
It is because I have modified the way the "knit html" button works. To include a table of content on my html pages, I followed the Rstudio advice on Customize Markdown Rendering. And created an .Rprofile file at the root of the project directory that overrides default markdown rendering options. My .Rprofile only contains a function that replaces the rstudio.markdownToHTML() function as such:
options(rstudio.markdownToHTML =
function(inputFile, outputFile) {
require(markdown)
htmlOptions <- markdownHTMLOptions(defaults=TRUE)
htmlOptions <- c(htmlOptions, "toc")
markdownToHTML(inputFile, outputFile, options = htmlOptions)
}
)
With this .Rprofile, I'm happy to have an automatic table of content generated on all my .RmD documents. But equations are not rendered any more! Equations appear as plain text.
If I delete .Rprofile, reload R and click the "knit HTML" button in R Studio. Equations are rendered correctly but I don't have a table of content.
If I run :
knit2html("file.Rmd", "file.html",
options = c(markdownHTMLOptions(defaults=TRUE), "toc")))
Equations are rendered correctly and I have a table of content too.
Can you help me fix rstudio.markdownToHTML() so that it renders equations?
Edit 03 April 2014: Equations are visible if I open the html page in a web browser. They are not rendered in RStudio preview HTML pane. This might be an issue with the mathjax script not taken into account anymore by the Rstudio viewer?
Dason suggested me to post this as an answer.
Equations are visible if I open the html page in a web browser.
Equations are not rendered in RStudio preview HTML pane. This might be an issue with the Rstudio viewer?

Resources