Skip to content

enricomanlapig/asischunk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

asis_chunk

Insert code chunk calling asis engine into R Markdown documents. An RStudio addin.

Inserts:

By Enrico Manlapig

Main functions:

  • asis_chunk

Installation

Development version:

install.packages(“devtools”)

devtools::install_github(“EnricoManlapig/asischunk”)

Use

  • Install package
  • Add key command (e.g. mac: cmd-alt-shift-p, win: ctrl-alt-shift-p) by going to:
    • Tools > Addins > Browse Addins > Keyboard Shortcuts.
    • Find asis code chunk and select the field under Shortcut.
    • Press desired key command.
    • Press Apply.
    • Press Execute.
  • Press chosen key command inside an R Markdown document

The asis engine allows users to write markdown within chunks. These chunks can then be conditionally rendered using parameters defined in the YAML or elsewhere in the document.

Example

By assigning the addin a keyboard shortcut, the addin gives the user a shortcut to the asis engine. The asis function is useful when the author intends to create different texts from the same document. For example, a teacher may want to render a version with a prompt for students and another version with solutions.

```{r toggle_solutions}
solutions <- TRUE
```

What is half of $4x$?

```{asis student_prompt, include = !solutions}
Write your answer here: 
```

```{asis instructor_solutions, include = solutions}
Correct answer: $\frac{4x}{2}= 2x$
```

If the object solutions takes the value FALSE, then the first chunk, student_prompt, is rendered. If solutions takes the value TRUE, then the second chunk, instructor_solutions, is rendered.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages