我想要計算平均值和標準偏差從成對在列表鏡像矩陣和寫一個表供進一步文本遊行:級聯中的R 2個細胞與±符號
mean_SG<- as.data.frame(lapply(list_SG, function(x) mean(x[upper.tri(x)])))
sd_SG <- as.data.frame(lapply(list_SG, function(x) sd(x[upper.tri(x)])))
write.table(t(rbind(round(mean_SG,3),round(sd_SG,3))), "SG.txt")
我的想法是直接串聯的來自mean_SG和sd_SG的帶有正負符號±的數字值,並將其寫入單個列中,並寫入write.table。 R中可能嗎?
下面是一些數據:
SG <- structure(c(85, 84.016, 82.9, 79, 85.167, 83.467, 78.5, 83.051,
80.064, 81.436, 79.94, 83.731, 83.468, 82.775, 83.294, 81.608,
82.176, 84.138, 82.6, 85.325, 82.297, 81.546, 83.569, 84.561,
87.039, 92.45, 86.35, 83.153, 84.447, 81.899, 81.972, 81.32,
81.949, 82.101, 0.656, 0.966, 1.833, NA, 0.643, 0.459, 0.608,
1.189, 1.024, 0.848, 1.207, 0.66, 0.757, 1.235, 0.872, 1.308,
0.958, 1.151, 0.914, 1.302, 0.708, 0.79, 1.349, 0.799, 1.297,
2.554, 0.55, 1.041, 1.216, 1.065, 0.981, 0.937, 1.133, 1.302), .Dim = c(34L,
2L), .Dimnames = list(c("X19_vs_11B.2", "X19_vs_AT.s3.28", "X19_vs_B276.D12",
"X19_vs_BP.U1C.1g10", "X19_vs_d142", "X19_vs_FFCH5909", "X19_vs_GBS.L1.B05",
"X19_vs_SG01", "X19_vs_SG02", "X19_vs_SG03", "X19_vs_SG04", "X19_vs_SG05",
"X19_vs_SG06", "X19_vs_SG07a", "X19_vs_SG07b", "X19_vs_SG08.Aca",
"X19_vs_SG08.Holo", "X19_vs_SG09", "X19_vs_SG10", "X19_vs_SG11",
"X19_vs_SG12", "X19_vs_SG13", "X19_vs_SG15", "X19_vs_SG17", "X19_vs_SG18",
"X19_vs_SG19", "X19_vs_SG20", "X19_vs_SG21", "X19_vs_SG22", "X19_vs_SG23",
"X19_vs_SG25", "X19_vs_SG26", "X19_vs_ThAna", "X19_vs_TPD.58"
), c("1", "2"))
你的意思是這個符號'x%+ - %y'? – Sotos
或'paste('a','b',sep =「±」)' – Heroka
我想以典型的平均值±sd(或sem)樣式爲手稿中的表格使用它。 – nouse