This FAQ is compiled from the issues and messages I received from blog posts and emails, etc. Personally I’m not big fan of FAQ’s, and I believe sometimes FAQ’s are nearly bugs, so I wish to keep the list short.
-
knitr does not work…
- Please first update all your R packages (use
update.packages()) and probably R itself (what is the current R version?), then see if it works; if not, please file an issue to me with a minimal reproducible example and the output ofxfun::session_info('knitr').
- Please first update all your R packages (use
-
What is the best place to ask questions when the package website is not helpful?
- Depending what you want to ask, you may use these tools (I keep track of the first two more frequently):
- (Recommended) Stack Overflow: general questions (more experts and quicker answers there). Don’t forget to use both the tags
randknitr. - GitHub issues: bug reports and feature requests only.
- Private emails are not recommended unless there are really private issues.
- Twitter (@xieyihui) if you really believe it is a simple question.
- (Recommended) Stack Overflow: general questions (more experts and quicker answers there). Don’t forget to use both the tags
- Depending what you want to ask, you may use these tools (I keep track of the first two more frequently):
-
What is the best editor for writing knitr source documents?
-
Where are those prompt characters
>and+? I feel uncomfortable reading R output without them.- They are removed by default, because I believe they make no sense. This is the reason why I dislike books on R which used
>and+; they twist my mind and make my eyes bleed when I read the R code in the books. For those who really want to read R code like> 1+1instead of1 + 1, you have the chunk optionprompt.
- They are removed by default, because I believe they make no sense. This is the reason why I dislike books on R which used
-
What is the working directory? Can I change my working directory in my code chunks?
- You’d better not do this. Your working directory is always
getwd()(all output files will be written here), but the code chunks are evaluated under the directory where your input document comes from. Changing working directories while running R code is a bad practice in general. See #38 for a discussion. You should also try to avoid absolute directories whenever possible (use relative directories instead), because it makes things less reproducible. If you do still decide to usesetwdin a code chunk, beware that the new working directory will only apply to that specific code chunk, and any following code chunks will revert back to use the original working directory.
- You’d better not do this. Your working directory is always
-
The gray (shading) box is too narrow for my output.
- No, it is not because the box is too narrow (the box uses the current line width); it is because your output is too wide. Use a smaller
widthoption to avoid text output exceeding the page margin, e.g.options(width = 60)(see example 038).
- No, it is not because the box is too narrow (the box uses the current line width); it is because your output is too wide. Use a smaller
-
How can I write a literal / verbatim code chunk? i.e., write a code chunk that is not parsed (which can be useful for tutorials).
-
For code chunks, you can use the
verbatimengine, e.g.,````{verbatim} ```{r, eval=TRUE} 1 + 1 ``` ```` -
For inline R code, you may use the function
knitr::inline_expr(). If you are writing an R Markdown document, you can use a trick: break the line right after`r(no spaces after it), and wrap the whole inline expression in a pair of double backticks, e.g.,This will show a verbatim inline R expression `` `r 1+1` `` in the output.See this post for explanations if you are curious.
-
-
How can I submit a documentation fix or other minor changes?
- To fix anything in the R package: navigate to the file within the repository; click the Edit button on the top-right toolbar; make the necessary changes; add a descriptive commit summary, click on Propose file change, and submit the pull request.
- To fix anything or propose changes on any page of this website, please click on the menu
Edit this pageon the left of the page, and follow the same steps on GitHub.
Donate
As a freelancer (currently working as a contractor) and a dad of three kids, I truly appreciate your donation to support my writing and open-source software development! Your contribution helps me cope with financial uncertainty better, so I can spend more time on producing high-quality content and software. You can make a donation through methods below.
-
Venmo:
@yihui_xie, or Zelle:xie@yihui.name -
Paypal
-
If you have a Paypal account, you can follow the link https://paypal.me/YihuiXie or find me on Paypal via my email
xie@yihui.name. Please choose the payment type as “Family and Friends” (instead of “Goods and Services”) to avoid extra fees. -
If you don’t have Paypal, you may donate through this link via your debit or credit card. Paypal will charge a fee on my side.
-
-
Other ways:
WeChat Pay (微信支付:谢益辉) Alipay (支付宝:谢益辉) 

When sending money, please be sure to add a note “gift” or “donation” if possible, so it won’t be treated as my taxable income but a genuine gift. Needless to say, donation is completely voluntary and I appreciate any amount you can give.
Please feel free to email me if you prefer a different way to give. Thank you very much!
I’ll give back a significant portion of the donations to the open-source community and charities. For the record, I received about $30,000 in total (before tax) in 2024-25, and gave back about $15,000 (after tax).