knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
#library(SemesterProjectLabII)
#library(pkgdown)

Your task is to convert the data to long format, and store the long-format data in a data.frame or tibble. Print out some of the long-form data in your lab1.Rmd, to show that you did make the appropriate conversion. For extra fun, show two different ways to solve the problem.

If you need to modify the excel by hand to help you solve the problem that is OK, just make a note of it in your lab work.

library(readxl)

wide_data <- read_xlsx("data/Lab1_data.xlsx")
library(tidyr)

library(dplyr)


participant <- wide_data$...1
Noisy_Morning_A <- wide_data$Noisy
Noisy_Morning_B <- wide_data$...3
Noisy_Afternoon_A <- wide_data$...4
Noisy_Afternoon_B <- wide_data$...5
Noisy_Evening_A <- wide_data$...6
Noisy_Evening_B <- wide_data$...7
Quiet_Morning_A <- wide_data$Quiet
Quiet_Morning_B <- wide_data$...9
Quiet_Afternoon_A <- wide_data$...10
Quiet_Afternoon_B <- wide_data$...11
Quiet_Evening_A <- wide_data$...12
Quiet_Evening_B <- wide_data$...13
Noise <- rep( rep(c("Noisy","Quiet"),each=6),10)
 Time    <- rep( rep(rep(c("Morning","Afternoon","Evening"),each=2),2), 10)
 condition   <- rep( rep(c("A","B"),6), 10)
 Participant <- rep(1:10, each = 12)

 wide_data <- read_xlsx("data/Lab1_data.xlsx",
                           range = "B4:M13", 
                           col_names=FALSE)

 long_dv <- c(t(as.matrix(wide_data)))

 long_data <- data.frame(Participant,
                         Noise,
                         Time, 
                         condition,
                         DV=long_dv)

 knitr::kable(long_data)


AmandaPMurphy/SemesterProjectLabII documentation built on May 23, 2022, 3:16 p.m.