--- title: "Examples" output: word_document: default pdf_document: default html_notebook: 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 *pivot_wider()* and *pivot_longer()*. ```{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 %>% pivot_wider(names_from = "when", values_from = "spb") BP_wide ``` ```{r} BP_narrow_new <- BP_wide %>% pivot_longer(c("before", "after"), names_to = "when", values_to = "spb" ) BP_narrow_new ```