我试图在1小时内解决这个问题,我对此感到厌倦。也许我的大脑今天不能正常工作。你能告诉我这段代码有什么问题吗?
gdata = lapply(list_of_data,function(x) x[3:nrow(x),10:13])
Error in `[.data.frame`(x, 3:nrow(x), 10:13) :
undefined columns selected
Called from: `[.data.frame`(x, 3:nrow(x), 10:13)
Browse[1]>
list_of_data:
dput(list_of_data,1)
.Names = c("X", "X.1", "X.2", "X.3", "X.4", "X.5",
"X.6", "X.7", "X.8", "Normalized.abundance", "X.9", "X.10", "X.11",
"X.12", "X.13", "X.14", "X.15", "Raw.abundance", "X.16", "X.17",
"X.18", "X.19", "X.20", "X.21", "X.22", "Spectral.counts", "X.23",
"X.24", "X.25", "X.26", "X.27", "X.28", "X.29", "X.30"), class = "data.frame", row.names = c(NA,
-803L)))
我必须马上解决它......
编辑:
> lapply(lapply(list_of_data[1:2], head), function(x) x[3:nrow(x),10:13])
[[1]]
Normalized.abundance X.9 X.10 X.11
3 1668438.99739286 911058.646307132 821546.715677381 1334363.36271572
4 2804563.91944008 1296422.89771343 1150958.22016359 1912269.47952259
5 213815.266100531 143536.606930572 88052.1808884685 133482.144742128
6 552208.112032517 287739.869317541 174403.271823509 259222.230879321
[[2]]
Normalized.abundance X.9 X.10 X.11
3 39695515.4271079 30712991.9845821 37323861.8240515 24967632.9381311
4 25166823.7872243 27548423.4403439 30030397.4398236 20891227.9569187
5 44789448.9907151 53207987.0690396 48833564.6040359 45792575.205227
6 11576801.6642989 10420163.7229766 11107757.0429856 8581636.03704784
但是仍然无法从函数中输出整个输出,所以我会复制最后一部分:
dput(lapply(list_of_data[1:2], head))
class = "factor"), Spectral.counts = structure(c(30L,
15L, 21L, 6L, 17L, 18L), .Label = c("0", "1", "10", "11",
"12", "13", "14", "15", "16", "17", "18", "19", "2", "20",
"20130107_SizeFractionation_EOD_EON_Fract10_S1", "21", "24",
"25", "27", "28", "29", "3", "36", "4", "5", "6", "7", "8",
"9", "EOD"), class = "factor"), X.21 = structure(c(1L, 14L,
22L, 10L, 15L, 12L), .Label = c("", "0", "1", "10", "11",
"12", "13", "14", "15", "16", "17", "19", "2", "20130107_SizeFractionation_EOD_EON_Fract10_S5",
"21", "23", "24", "25", "26", "27", "3", "31", "32", "4",
"5", "6", "7", "8", "9"), class = "factor"), X.22 = structure(c(1L,
16L, 24L, 15L, 21L, 12L), .Label = c("", "0", "1", "10",
"11", "12", "13", "14", "15", "16", "17", "18", "19", "2",
"20", "20130107_SizeFractionation_EOD_EON_Fract10_S7", "21",
"22", "23", "25", "27", "3", "30", "32", "4", "41", "5",
"6", "7", "8", "9"), class = "factor"), X.23 = structure(c(30L,
15L, 18L, 11L, 21L, 20L), .Label = c("0", "1", "10", "11",
"12", "13", "14", "15", "16", "17", "18", "19", "2", "20",
"20130107_SizeFractionation_EOD_EON_Fract10_S2", "21", "22",
"27", "3", "30", "31", "33", "38", "4", "5", "6", "7", "8",
"9", "EON"), class = "factor"), X.24 = structure(c(1L, 15L,
19L, 11L, 18L, 13L), .Label = c("", "0", "1", "10", "11",
"12", "13", "14", "15", "16", "17", "18", "19", "2", "20130107_SizeFractionation_EOD_EON_Fract10_S4",
"21", "22", "26", "28", "3", "32", "39", "4", "5", "6", "7",
"8", "9"), class = "factor"), X.25 = structure(c(1L, 16L,
22L, 10L, 17L, 19L), .Label = c("", "0", "1", "10", "11",
"12", "13", "14", "15", "16", "17", "18", "19", "2", "20",
"20130107_SizeFractionation_EOD_EON_Fract10_S6", "23", "24",
"25", "28", "3", "30", "33", "38", "4", "5", "6", "7", "8",
"9"), class = "factor"), X.26 = structure(c(1L, 15L, 23L,
12L, 21L, 18L), .Label = c("", "0", "1", "10", "11", "12",
"13", "14", "15", "17", "18", "19", "2", "20", "20130107_SizeFractionation_EOD_EON_Fract10_S8",
"21", "22", "23", "25", "26", "27", "3", "30", "34", "35",
"4", "5", "6", "7", "8", "9"), class = "factor"), X.27 = structure(c(3L,
2L, 1L, 1L, 1L, 1L), .Label = c("", "score 70", "Tags"), class = "factor"),
X.28 = structure(c(1L, 2L, 1L, 1L, 1L, 1L), .Label = c("",
"min 1.4 fold"), class = "factor"), X.29 = structure(c(1L,
2L, 1L, 1L, 1L, 1L), .Label = c("", "new score 70"), class = "factor"),
X.30 = c(NA, NA, NA, NA, NA, NA)), .Names = c("X", "X.1",
"X.2", "X.3", "X.4", "X.5", "X.6", "X.7", "X.8", "Normalized.abundance",
"X.9", "X.10", "X.11", "X.12", "X.13", "X.14", "Raw.abundance",
"X.15", "X.16", "X.17", "X.18", "X.19", "X.20", "Spectral.counts",
"X.21", "X.22", "X.23", "X.24", "X.25", "X.26", "X.27", "X.28",
"X.29", "X.30"), row.names = c(NA, 6L), class = "data.frame"))