--- title: "Examples" output: word_document: default html_notebook: default pdf_document: default --- In this example we will look at a dataset that might be used with the pair t-test. # Example of *tibble()* and *tribble()* functions to create a data_frame. ```{r message=FALSE} library(tidyverse) BP_narrow <- tibble( x = c("a", "b"), y = c(1,2), z = c(3.6, 8.5) ) BP_narrow <- tribble( ~x, ~y, ~z, "a", 2, 3.6, "b", 1, 8.5 ) ``` # Example of *spread()* and *gather()*. ```{r} BP_narrow <- tribble( ~subject, ~when, ~spb, "BHO", "before", 160, "GWB", "before", 120, "WJC", "before", 105, "BHO", "after", 115, "GWB", "after", 135, "WJC", "after", 145 ) ``` ```{r} BP_wide <- BP_narrow %>% spread(key = when, value = spb) BP_wide ``` ```{r} BP_narrow <- BP_wide %>% gather(key = when, value = spb, after, before) BP_narrow ```