Created
October 6, 2022 04:54
-
-
Save jenrichmond/43b83005969ad27c3a2b3acd3078cb44 to your computer and use it in GitHub Desktop.
use knitr::spin to convert script to markdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' this script demos how to use knitr::spin to turn a .R script into a knitted markdown | |
#' these funny hash/tick comments will be read in the .md doc as text | |
#' everything else will be run as a code chunk | |
#' to use spin, in the console run knitr::spin(file = spintest.R) | |
#' you will end up with a .md doc in your files, open it and knit to html | |
#' load packages | |
library(tidyverse) | |
library(palmerpenguins) | |
#' print p values not in scientific notation | |
options(scipen = 99) | |
#' filter penguin data to include just adelie and gentoo | |
ag <- penguins %>% | |
filter(species %in% c("Adelie", "Gentoo")) | |
# boxplot body mass by species | |
ag %>% | |
ggplot(aes(x = species, y = body_mass_g)) + | |
geom_boxplot() | |
#' t-test body mass by species | |
t.test(body_mass_g ~ species, data = ag) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment