I cannot use knit to word ,pdf

When I tried to use knit error message:
[WARNING] This document format requires a nonempty element.
Defaulting to 'nelu.knit' as the title.
To specify a title, use 'title' in metadata or --metadata title="...".

Output created: nelu.html

Try to create a simple Rmd file that you can knit to Word.

The easiest way to do that is with File in the RStudio menu:
File | New File | R Markdown...  and then select the Word button and click OK .
An .Rmd-file is then generated for you (but not yet saved).
So save it with an .Rmd extension and click the knitr button.

On my computer it produces a .docx files that is immediately opened by Word.
I think it depends on the settings of your computer if Word opens the file automatically or not.

Anyway: the first lines of the .Rmd file shows the 'YAML' lines that are necessary to let knitr do its work:

---
title: "Untitled"
author: "My name"
date: "2022-08-31"
output: word_document
---


Your warnings suggest that there is something wrong with the YAML lines that you have used.

1 Like

Yes this warning means that somehow your document is missing a title: or have a title: that cause an issue. Can you share more about the content ?

knitr::opts_chunk$set(echo = TRUE)  R Markdown This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com. When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this: summary(cars)  Including Plots You can also embed plots, for example: plot(pressure)  Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot. Your header looks good, but it is essential that this header is started and ended with ---. Sorry doesn work "C:/Users/silhda/ANACON~1/envs/rstudio/Scripts/pandoc" +RTS -K512m -RTS asa.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output asa.html --lua-filter "C:\Users\silhda\Documents\R\win-library\4.0\rmarkdown\rmarkdown\lua\pagebreak.lua" --lua-filter "C:\Users\silhda\Documents\R\win-library\4.0\rmarkdown\rmarkdown\lua\latex-div.lua" --self-contained --variable bs3=TRUE --section-divs --template "C:\Users\silhda\Documents\R\win-library\4.0\rmarkdown\rmd\h\default.html" --no-highlight --variable highlightjs=1 --variable theme=bootstrap --mathjax --variable "mathjax-url=https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" --include-in-header "C:\Users\silhda\AppData\Local\Temp\RtmpE3pt1k\rmarkdown-stree4420f24a9.html" [WARNING] This document format requires a nonempty element. Defaulting to 'asa.knit' as the title. To specify a title, use 'title' in metadata or --metadata title="...". Output created: asa.html but asa .html are empty instead of size 713Kb Can you format your code correctly so that we can check that the Rmd file is ok ? FAQ: How to Format R Markdown Source Also can you share the results of rmarkdown::pandoc_version() ? Thank you ! It is normal code when start new rmatkdown file It is still good practice to format your code correctly. Can you share the result of rmarkdown::yaml_front_matter run on your input file ? Also what are your tools versions ? I can't reproduce using default template document with latest version of tools. title: "EXEMPLU" author: "Dan" date: "September 12, 2022" output: html_document: toc: yes pdf_document: default word_document: default knitr::opts_chunk$set(echo = TRUE)

summary(cars$dist) summary(cars$speed)


Below error
"C:/Users/silhda/ANACON~1/envs/rstudio/Scripts/pandoc" +RTS -K512m -RTS etc.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output etc.html --lua-filter "C:\Users\silhda\Documents\R\win-library\4.0\rmarkdown\rmarkdown\lua\pagebreak.lua" --lua-filter "C:\Users\silhda\Documents\R\win-library\4.0\rmarkdown\rmarkdown\lua\latex-div.lua" --self-contained --variable bs3=TRUE --section-divs --template "C:\Users\silhda\Documents\R\win-library\4.0\rmarkdown\rmd\h\default.html" --no-highlight --variable highlightjs=1 --variable theme=bootstrap --mathjax --variable "mathjax-url=https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" --include-in-header "C:\Users\silhda\AppData\Local\Temp\RtmpQFbmPA\rmarkdown-str6e0383229e2.html"
[WARNING] This document format requires a nonempty element.
Defaulting to 'etc.knit' as the title.
To specify a title, use 'title' in metadata or --metadata title="...".

Output created: etc.html.ETC.html are empty

I instaled Rstudio from Anaconda

You keep posting the same error message, but that don't help us to help you.

I don't use RStudio from anaconda. Useful information:

• Which version of RStudio it is ? Is it the latest ?
• Which version of Pandoc is used ? rmarkdown::pandoc_version()
• Which version of rmarkdown is used ? Did you update to latest ?

With issue like that we can't reproduce, it is sometimes related to the user environment. Please to update the tools. I don't know how Anaconda maintain the software, but if you can use R and R Studio outside of anaconda, especially if they don't have latest version that may fix things

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.