assignr icon indicating copy to clipboard operation
assignr copied to clipboard

Directions / Assignment Chunks

Open daviddalpiaz opened this issue 7 years ago • 12 comments

Currently cannot be used for both r and asis engines.

daviddalpiaz avatar Feb 06 '18 16:02 daviddalpiaz

I think this is wanting to add another flag to processing?

I'm not sure we can easily embed code chunks in directions...

A sample document.

```{asis, directions = TRUE}

Some directions
```{r}
1 + 1  # a line of code
```

```

Another paragraph.

Readability wise, this doesn't work out nicely.

coatless avatar Feb 06 '18 16:02 coatless

I'm not sure what that example is showing. I don't see the need to have one chunk inside of another.

daviddalpiaz avatar Feb 06 '18 17:02 daviddalpiaz

The starting issue is a bit sparse. Did you mean something along the lines of:

```{asis, directions = TRUE}
Text
```

```{r, directions = TRUE}
# code
```

going to:

Text

# code

e.g. there is no discrimination between tag placement?

coatless avatar Feb 06 '18 17:02 coatless

Written in lab00-main.Rmd:

```{asis, assign = TRUE}
Text
```

```{r, assign = TRUE}
# your code here
```

Becomes in lab00-assign.Rmd:

Text

```{r}
# your code here
```

daviddalpiaz avatar Feb 07 '18 01:02 daviddalpiaz

So, we can use this to determine the asis chunk:

asis.*?,.*?directions[[:space:]]?=[[:space:]]?[tT]?[rR]?[uU]?[eE]?

And we can force remove in the r chunk with:

,?[[:space:]]?directions[[:space:]]?=[[:space:]]?[tT]?[rR]?[uU]?[eE]?

coatless avatar Feb 07 '18 02:02 coatless

As of now, can I include R code only in *-assign.Rmd but not in *-sol.Rmd?

inmybrain avatar Dec 02 '20 06:12 inmybrain

As of now, can I include R code only in *-assign.Rmd but not in *-sol.Rmd?

If a code chunk is marked by:

  • solution = TRUE, only display in *-sol.Rmd.
  • directions = TRUE: only display in *-assign.Rmd
  • Neither solution = TRUE or directions = TRUE: display in both *-sol.Rmd and *-assign.Rmd

These two keywords are hard-wired at the moment:

https://github.com/r-assist/assignr/blob/4b1c75717fc6141ab8490db77ca7b116907301a4/R/assignr.R#L256-L266

coatless avatar Dec 02 '20 06:12 coatless

@coatless Thanks, but sorry I don't get it here.

What I want to do is

```{r, directions = TRUE}
1+1
```

which only returns the plain text "1+1".

I want it to generate R code only in *-assign.Rmd. Is this currently supported?

inmybrain avatar Dec 02 '20 06:12 inmybrain

@inmybrain unfortunately, no. The directions= option is only supported under asis.

coatless avatar Dec 02 '20 06:12 coatless

@coatless Thanks for the clarification. Is there any possibility to include such an option?

inmybrain avatar Dec 02 '20 06:12 inmybrain

@inmybrain not until the weekend. My mind is on a paper deadline.

coatless avatar Dec 02 '20 06:12 coatless

@coatless Oh I didn't mean to rush you at all. Please take your time and consider including the option when you have time. Wish you finish your paper by the due date.

inmybrain avatar Dec 02 '20 06:12 inmybrain