1
鑑於突變行:摺疊因素和與dplyr
x <- data.frame(Day = c(1,2,3,4,5,6,7,8,9,10),
var1 = c(5,4,2,3,4,5,1,2,3,4),
var2 = c(3,6,2,3,4,5,7,8,1,2),
var3 = c(1,2,3,4,6,2,4,7,8,4),
var4 = c(1,3,7,5,3,7,2,3,1,2))
此刻一天變量是數字,但對應於1 =星期一,5 =星期五,6 =星期一,10 =星期五。我想所有的各天坍塌在一起,並通過日平均它們的值了:
z <- data.frame(Day = c("Monday", "Tuesday", "Wednesday", "Thursday","Friday"),
var1 = c(5,2.5,2,3,4),
var2 = c(4,6.5,5,2,3),
var3 = c(1.5,3,5,6,5),
var4 = c(4,2.5,5,3,2.5))