Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
36 lines (33 sloc) 5.526 kB

Frequently Asked Questions

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. Software package authors should think why users ask some questions so frequently (it is unlikely that users are always stupid). At least I'm not patient enough to read, say, 128 FAQ's one by one, so I won't let you do it, either.

  1. 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 of library(knitr); sessionInfo().
  2. 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 three more frequently):
    • (Recommended) StackOverflow: general questions (more experts and quicker answers there).
    • Github issues: bug reports and feature requests.
    • knitr mailing list or R-help list: general questions and feedback via email in public.
    • Private email is the least recommended way unless there are really private issues.
    • Twitter (@xieyihui) or Google+ (+Yihui Xie).
  3. How should I get started?
  4. What is the best editor for writing knitr source documents?
  5. 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+1 instead of 1 + 1, you have the chunk option prompt.
  6. 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 use setwd in 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.
  7. 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 width option to avoid text output exceeding the page margin, e.g. options(width = 60) (see example 038).
  8. How can I write a literal code chunk? i.e. write a code chunk which is not parsed and useful for tutorials?
    • You need to destroy the chunk header, e.g. add an empty string before the chunk header: \Sexpr{''}<<label, what=ever>>=, or `r ''` ```{r label, what=ever} (#443), or add a zero-width space into the chunk header; see example 065
    • For inline R code, you may use the function knitr::inline_expr() (available in knitr >= v1.8)
  9. What can I do for you?
    • Many things, e.g. donate zillions to me (well, I'm kidding), buy me a gift from my Amazon wishlist, tweet funny GIF animations to me, mention knitr on Google+ or Facebook, or fork this repository and contribute code, or just say hello to me somewhere.
    • Cite the package and the knitr book; see citation('knitr') in R.
  10. How can I submit a documentation fix or other minor change?
    • Navigate to the file within the repo
    • Click on the edit button
    • Make the necessary changes.
    • Add a descriptive commit summary and click on propose file change
    • Submit the pull request
Jump to Line
Something went wrong with that request. Please try again.