I am trying to put the references as bib tex with b-9.bib and with some styling with .csl files. Both the Rmarkdown and the aforementioned files are present in the same working directory. But I am encountering this error when trying to knit to PDF.
YAML Header
---
title: "Swarm Intelligence"
output: html_document
bibliography: b-9.bib
csl: ieee.csl
---
Not sure if it is because of the hyphenated naming or path issue. I even tried giving the absolute path to the header path but still the issue. or am I missing some extra code chunk or so?
Ensure all your files have the same working directory. Also, try using "word_document" as the output format. I am not sure how your csl formatting would apply to a html document.
Related
How do I change an .Rmd file to an .md file, that I can then push to GitHub? I have knit to HTML
Is it possible to do this by something as simple as changing the file extension to ".md" and doing a save as? Any insight into what the differences are amongst these types of files would be so helpful!
Also, how different should an .Rmd and .md file look when opened?
Thank you!
You can add keep_md to your YAML header.
---
output:
html_document:
keep_md: true
---
Just be aware you will need to also push any related assets to Github as well as the .md file
You can use
knitr::knit("my_file.Rmd")
which should output my_file.md (a Markdown file with included code chunks) and generate figures (in a figs/ directory, I think, not sure).
I am trying to include a bibliography into a revealjs presentation using rmarkdown. However, despite the apparent inclusion of the bibliography in the pandoc processing (the pandoc command generated by rmarkdown includes the bib file and the citeproc filter), the generated html does not include the references. Using a different slide presentation generator and rmarkdown, such as ioslides, correctly includes the references. I was not able to find any obvious statement abuot supporting bibliography processing with rmarkdown and revealjs. Is it possible?
As a workaround you can try the following:
create a separate Rmd-file and adapt the following:
---
output: html_document
bibliography: pathtomybibfile.bib
nocite: |
#cite, #all, #your, #references
---
generate html-version of this file (e.g. name it bib.html)
include html within your revealjs-presentation via:
# {data-background-iframe="bib.html"}
I'm trying to use RMarkdown to write posts about R for my blog (that uses Jekyll). Quite smooth except for one minor annoyance: I can't find a way to specify the output file inside the .Rmd document. By default, the output has the same name as the original document, only with a .md extension. I don't want to use the same name for both files because I follow the Jekyll convention of prefixing the .md files with the date, something that's not always necessary for the .Rmds.
I tried using the output_file argument on the front matter, but it didn't work. My hope is that there's a subtle way of passing parameters to rmarkdown::render from inside the document.
Here's a sample YAML front matter (does not work):
---
output:
md_document:
output_file: "2017-05-19-computacao-simbolica-R-2-4.md"
variant: markdown_github
html_document: null
---
Can I add more than one custom css file into R Markdown file?
I found that, add the following code in the head, I can add a customer css file.
html_document:
css: /css/my1.css
But this method just allowed one css file. Is it possible add more than one customer css file into a Rmd file?
By poring through the sources I eventually figured out that the output portion of the Rmd headers can be specified as an R function. Here is a header I use as part of my diffobj package to get two CSS files in:
---
title: "diffobj - Diffs for R Objects"
author: "Brodie Gaslam"
output:
function(...) rmarkdown::html_vignette(..., md_extensions="-markdown_in_html_blocks", css=c(file.path(system.file(package="diffobj"), "css", "diffobj.css"), "styles.css")):
toc: true
vignette: >
%\VignetteIndexEntry{diffobj}
%\VignetteEngine{knitr::rmarkdown}
\usepackage[utf8]{inputenc}
---
You can skip the md_extensions part for your purposes. The key is what happens with the css argument. With that argument I specify the following two files:
file.path(system.file(package="diffobj"), "css", "diffobj.css"), from my package
"styles.css", in the same folder as the vignette Rmd
The above is in the context of using devtools::build_vignettes(), but I imagine you can use a similar solution in your situation.
Using RStudio's "Compile Notebook to html" feature, I noticed that a temporary .md file was created in the process, but deleted automatically. At one point I was lucky enough to see its content, and it is exactly what I need: the code chunks alternate with output chunks, all perfectly formatted.
So my question is: how do I generate such an .md file directly form an R script?
You could also run knitr::spin() directly from the R console.
If you run "Knit to HTML", a markdown file is temporarily created and deleted. To keep the markdown file, add the following to the YAML code at the top of the RMD file.
---
output:
html_document:
keep_md: true
---
Here is a helpful reference: https://bookdown.org/yihui/rmarkdown/html-document.html#keeping-markdown