87
These Markdown Editor let you write and edit markup documents. Use these markdown editor freeware to convert markdown to HTML and PDF. Introduction RStudio offers the opportunity to build MS Word documents from RMarkdown files. However, since formatting options in Markdown are very limited, there is no 'native' Markdown code to. R Markdown output format to pass to render. Finding stylenames. You can access them in the Word template used. Function stylesinfo can let you read these styles. You need officer to read the stylenames (to get information from a specific 'referencedocx', change refdocxdefault in the example below.
Даже с очень простым Rmd файлом, сгенерированным последовательностью
'Newfile' -> 'New R Markdown'
, выбирая 'Document' и 'PDF' в качестве формата вывода по умолчанию, я получаю следующую ошибку при нажатии кнопки 'Knit PDF' в RStudio:R Markdown To Word
Информация о сеансе R, предоставляемая
sessionInfo()
, дает:В окне 8.1. Я использую:
- Версия MikTeX 2.9.5721
Pandoc 1.15.1.1.
RStudio 0.99.489
Все библиотеки были обновлены сегодня (17 ноября 2015 г.). Кроме того, все программное обеспечение было установлено с правами администратора в установках по умолчанию на диске C: и было доступно для всех пользователей.
Записывать Rmd файл в HTML и Word без проблем.
Любое предложение, как решить проблему?
Любое предложение, как решить проблему?
There are some things that I run into fairly frequently (and some not so much) when I’m rendering my rmarkdown documents. This section details some the common problems, and the solution that I have found works for me.
If you want to practice on fixing broken rmarkdown documents, check out some pathologically broken examples on github at njtierney/rmd-errors.
15.1 Avoiding problems
To avoid problems in the first place, I try and do the following:
- Develop code in chunks and execute the chunks until they work, then move on.
- knit the document regularly to check for errors.
Then, if there is an error:
- recreate the error in an interactive session:
- restart R
- run all chunks below
- find the chunk that did not work, fix until it does
- run all chunks below
- explore working directory issues
- remember that the rmarkdown directory is where the .Rmd file lives
15.2 The errors
What follows from here are all the errors you might in an rmarkdown document, with the following structure:
- What they might look like
- What the error message might appear to be, and
- How to solve them
15.3 “Duplication”: Duplicated chunk names
What it might look like
Chunks like this:
The error message
This is caught before the document compiles with a warning like:
The important part to note is the start:
How to solve
- In our case we have the same chunk name twice: ‘title-one’. Change the chunk name of one of them!
15.4 “Not what I ordered”: Objects not created in the right order
What it might look like
The error message
How to solve
15.5 “Forgotten Trails I”: Missing “,”, or “(”, “}”, or “’”
What it might look like
The error message
How to solve
15.6 “Forgotten Trails II”: Chunk option with trailing ', or not input
What it might look like
The error message
How to solve it?
- The easiest way is to do Cmd+Shift+F, which opens up a global search in your rstudio project, and then type in the offending string mentioned in the NOTE. In this case, I would search for the partial string
'fig.cap = 'Setting the options right for rstudio, so you don't restore previous sessions work, and
. I search for the partial string because there might be parts at the end of the error message that aren’t in the text.
15.7 “Forgotten Trail III”:
Rmarkdown Word Font Size
What it might look like
The error message
How to solve
This error message is pretty good, I needed to add a comma after my chunk name.
So, go from:
to
15.8 “The Path Not Taken” File path incorrect
What it might look like
The error message
How to solve
15.9 “Spolling I” Incorrectly spelled chunk options
These are often not an error, but you just won’t get the behaviour that you expect.
What it might look like
fig.caption
instead offig.cap
. This once caused me to rewrite a lot of code and an entire section of a paper until I realised the problem.
The error message
![Word Word](/uploads/1/1/8/2/118262919/188039730.png)
How to solve
![Rmarkdown Word Rmarkdown Word](/uploads/1/1/8/2/118262919/805697520.png)
- There might be a switch you can flick to ask
knitr
to solve
15.10 “Spolling II” Incorrectly spelled chunk option inputs
So this is when you provide the wrong input to your chunk options. Like something that requires
TRUE
gets “yes”, or something that needs '100%'
instead gets 100
What it might look like
The error message
How to solve
What was the problem? Turns out I provided the option
FALSe
instead of FALSE
.Go from:
to
15.11 “The Legend of Link I”: Your images in ![]()
don’t work.
I often forget that it is
![](path/to/image)
, and not ![]('path/to/image')
. There are no quote marks!15.12 LaTeX errors
There is no panacea for LaTeX errors, but if you aren’t familiar with “what that error message” might look like, here are some details.
What it might look like
The error message
How to solve
15.13 I want to include inline R code verbatim to show an example
… Like for a book on using rmarkdown or something.
Check out this great blog post by T. Hovorka from R Views
It boils down to this:
`` `r 'u0060r expressionu0060'` ``
.15.14 My Figure or Table isn’t being cited
What it might look like
You create a figure,
The error message
There isn’t one - you just get
@ref(fig:figure-chunk-name)
printed.Rmarkdown Word
How to solve
Rmarkdown Word Table
You need to make sure that you actually print the table or plot. If you create the plot and save it, but do not print it in the document, then you will not be able to reference the plot or table.
15.15 Your Turn
Rmarkdown Word Page Break
- Go to this repo njtierney/rmd-errors, and give debugging some of these common rmarkdown errors a go.