Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First R code chunk in R Markdown Disappears When Options Specified #280

Closed
jwpaulson opened this issue Jun 16, 2012 · 6 comments
Closed
Labels
bug Bugs
Milestone

Comments

@jwpaulson
Copy link

Using the latest version of knitr from github (0.6.1, but also repros with 0.5 from CRAN), the first R code chunk will disappear when any option is specified. For example if you place the following code into a test.Rmd file:

Test

```{r, echo=TRUE}
summary(cars)
```

Then calling the following command from R (being in the appropriate directory):

> knit("test.Rmd")

It will create a .md file with just Test and nothing else. This was discovered in RStudio, but was reproduced outside of RStudio with R 2.14.2 on a Mac running OS X 10.6.8.

http://support.rstudio.org/help/discussions/problems/2574-not-recognising-first-r-code-chunk-in-r-markdown

Let me know if you need any additional information to reproduce.

Josh

@Dasonk
Copy link

Dasonk commented Jun 16, 2012

Change it to

```{r echo=TRUE}

or

```{r thisisyourlabel, echo=TRUE}

The first argument after the r can't have a comma before it.

@yihui
Copy link
Owner

yihui commented Jun 16, 2012

Thanks, @Dasonk You are correct that @jwpaulson was using the wrong syntax. The correct syntax is ````{r options}, i.e. {r` followed by a space rather than a comma. The letter `r` is not part of chunk options; it is just part of the identifier.

@jwpaulson
Copy link
Author

I must have been really tired last night on the plane as that is an obvious error by me. I was trying to reproduce a few problems that users posted and thought I found two at once! Thanks for the immediate response and correction.

Josh

@yihui
Copy link
Owner

yihui commented Jun 18, 2012

You are not the only person who was confused by the syntax, so this could be well considered as a bug (my philosophy is FAQ's are nearly bugs). The fix will appear in my next push.

kohske pushed a commit to kohske/knitr that referenced this issue Jun 21, 2012
@yihui
Copy link
Owner

yihui commented Jun 22, 2012

@jwpaulson the comma after r will no longer cause problems after v0.6 (a new version will be on CRAN soon)

@github-actions
Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bugs
Projects
None yet
Development

No branches or pull requests

3 participants