Codes for Reshaping Data
Published by Haerim Hwang
reshaping data long to wide wide to long data science r
0 min READ
Open the sample CSV file you downloaded from the above link
data_summary_L2 <- read.csv(file.choose(), header = TRUE, stringsAsFactors = T)
Reshape data from a long format to a wide format
data_summary_L2 <- select(data_summary_L2, participant, proficiency, condition, judgment)
droplevels(data_summary_L2)
data_L2_wide = spread(data_summary_L2, key = "condition", value = "judgment")
Reshape data from a wide format to a long format
data_L2_long <- gather(data_L2_wide, condition, judgment, If_No_gap:Who_Gap, factor_key = TRUE)