Skip to content

Instantly share code, notes, and snippets.

@kylebutts
Created November 27, 2023 14:27
Show Gist options
  • Save kylebutts/1234037cd16ff9cbc9947137eb282e9c to your computer and use it in GitHub Desktop.
Save kylebutts/1234037cd16ff9cbc9947137eb282e9c to your computer and use it in GitHub Desktop.
#' ---
#' title: "Demo showing R code chunks, VSCode, and quarto support"
#' format: gfm
#' ---
#' This script shows how to use .Rmd chunks in a plain text file.
#' With new changes to vscode-R extension, this is seamlessly integrated
#' into the dev experience. Additionally, knitr::spin() or quarto
#' can be used to generate a report directly from the .R file.
# %% setup
#| warning: false
library(tidyverse)
library(here)
print("Welcome to the demo!")
# %% Generate data
v <- seq(-pi, pi, by = 0.01)
df <- tibble(x = v, y = sin(v))
# %% Plot data
#| fig.cap: "A plot of the sine function"
ggplot(df, aes(x, y)) +
geom_line() +
theme_gray(base_size = 14)
# %% quarto::render()
#| eval: false
library(quarto)
quarto_render(here("demo.R"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment