我有一个数据框列表。在每个数据帧中,我更改了每个数据帧中的第八,第九和第十列。我定义了一个向量,表示我想要更改的列中值的位置。
aa = seq(1, 168 , 24)
bb = rep(T, 168)
bb[aa] = FALSE
cc= (which(bb)) # vector of locations
func.8 = function(x) {
x[cc,8] = NA
return(x)
}
func.9 = function(x) {
x[cc,9] = NA
return(x)
}
func.10 = function(x) {
x[cc,10] = NA
return(x)
}
my.list= lapply( my.list, func.8)
my.list= lapply( my.list, func.9 )
my.list= lapply( my.list, func.10 )

我的问题是如何为我想要更改的所有列定义单个函数。我试过这个功能,但它没有好转:
func = function(x) {
x[cc,8:10] = NA
return(x)
}
my.list=(lapply my.list, func)
Error in `*tmp*`[[j]] : recursive indexing failed at level 2
可重复的示例
# LIST OF 5 DATAFRAMES OF 168 OBS (24*7) WITH RANDOMIZED DATA AND REPEATED LETTER ID
dfList <- lapply(1:5, function(i) {
set.seed(i+100)
data.frame(ID=LETTERS[1:7],
A=rnorm(168),
B=rnorm(168)+1000,
C=rnorm(168)*100)
})
func = function(X){
X[cc,3:4] = NA
return(X)
}
newList <- lapply(dfList, func)
newList[[1]]
# ID A B C
# 1 A -0.326036491 999.9986 53.89500
# 2 B 0.552461855 NA NA
# 3 C -0.674943844 NA NA
# 4 D 0.214359459 NA NA
# 5 E 0.310769217 NA NA
# 6 F 1.173966288 NA NA
# 7 G 0.618789856 NA NA
# 8 A -0.112734315 NA NA
# 9 B 0.917028290 NA NA
# 10 C -0.223259365 NA NA
# 11 D 0.526448099 NA NA
# 12 E -0.794844435 NA NA
# 13 F 1.427755545 NA NA
# 14 G -1.466819694 NA NA
# 15 A -0.236683379 NA NA
# 16 B -0.193337965 NA NA
# 17 C -0.849754740 NA NA
# 18 D 0.058465498 NA NA
# 19 E -0.817670356 NA NA
# 20 F -2.050307816 NA NA
# 21 G -0.163755666 NA NA
# 22 A 0.708522104 NA NA
# 23 B -0.267980546 NA NA
# 24 C -1.463921760 NA NA
# 25 D 0.744435823 1001.4524 -43.24300
# 26 E -1.410390181 NA NA
# ...
这是令人兴奋的&#39;列表:
> dput(kvish_1_10t.tables[1:2])
structure(list(X2005_kvish_1_10t = structure(list(kvish = c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L), keta = c(10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L), maslul = c(1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L), yom = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L),
nefah = c(2743L, 1759L, 1227L, 1077L, 1019L, 1181L, 2440L,
4257L, 4034L, 3539L, 3358L, 3323L, 3760L, 3876L, 4712L, 5622L,
5730L, 5931L, 5570L, 5147L, 4672L, 3829L, 2893L, 2227L, 1609L,
958L, 714L, 656L, 666L, 1028L, 2597L, 4006L, 4056L, 3441L,
3547L, 2927L, 4026L, 4461L, 5210L, 5974L, 6183L, 6137L, 6078L,
5664L, 4712L, 3652L, 2841L, 2381L, 1564L, 926L, 813L, 724L,
593L, 899L, 2424L, 4218L, 3888L, 3771L, 3589L, 3610L, 1319L,
4540L, 4966L, 4515L, 6229L, 6164L, 5837L, 5236L, 4935L, 3888L,
3003L, 2795L, 1931L, 1117L, 809L, 658L, 634L, 998L, 2539L,
4048L, 3762L, 3321L, 3483L, 3657L, 3855L, 4632L, 5118L, 5957L,
6046L, 6146L, 6169L, 5720L, 3843L, 3005L, 2166L, 1566L, 964L,
672L, 539L, 579L, 546L, 863L, 2489L, 4226L, 4256L, 3631L,
3351L, 3757L, 4014L, 4666L, 5046L, 5854L, 5743L, 6064L, 5811L,
5480L, 4932L, 3970L, 3027L, 2656L, 2284L, 1893L, 1815L, 1647L,
1395L, 1177L, 1443L, 2180L, 2642L, 2853L, 3073L, 3907L, 5052L,
5618L, 4907L, 4366L, 4384L, 4724L, 3059L, 2024L, 2334L, 1842L,
1933L, 2074L, 1817L, 1605L, 1562L, 1610L, 1327L, 1003L, 730L,
712L, 853L, 1461L, 2066L, 2476L, 2922L, 3084L, 2877L, 2894L,
3198L, 3538L, 3518L, 3606L, 3563L, 3455L, 3306L, 3181L),
date = structure(c(1114905600, 1114909200, 1114912800, 1114916400,
1114920000, 1114923600, 1114927200, 1114930800, 1114934400,
1114938000, 1114941600, 1114945200, 1114948800, 1114952400,
1114956000, 1114959600, 1114963200, 1114966800, 1114970400,
1114974000, 1114977600, 1114981200, 1114984800, 1114988400,
1114992000, 1114995600, 1114999200, 1115002800, 1115006400,
1115010000, 1115013600, 1115017200, 1115020800, 1115024400,
1115028000, 1115031600, 1115035200, 1115038800, 1115042400,
1115046000, 1115049600, 1115053200, 1115056800, 1115060400,
1115064000, 1115067600, 1115071200, 1115074800, 1115078400,
1115082000, 1115085600, 1115089200, 1115092800, 1115096400,
1115100000, 1115103600, 1115107200, 1115110800, 1115114400,
1115118000, 1115121600, 1115125200, 1115128800, 1115132400,
1115136000, 1115139600, 1115143200, 1115146800, 1115150400,
1115154000, 1115157600, 1115161200, 1115164800, 1115168400,
1115172000, 1115175600, 1115179200, 1115182800, 1115186400,
1115190000, 1115193600, 1115197200, 1115200800, 1115204400,
1115208000, 1115211600, 1115215200, 1115218800, 1115222400,
1115226000, 1115229600, 1115233200, 1115236800, 1115240400,
1115244000, 1115247600, 1115251200, 1115254800, 1115258400,
1115262000, 1115265600, 1115269200, 1115272800, 1115276400,
1115280000, 1115283600, 1115287200, 1115290800, 1115294400,
1115298000, 1115301600, 1115305200, 1115308800, 1115312400,
1115316000, 1115319600, 1115323200, 1115326800, 1115330400,
1115334000, 1115337600, 1115341200, 1115344800, 1115348400,
1115352000, 1115355600, 1115359200, 1115362800, 1115366400,
1115370000, 1115373600, 1115377200, 1115380800, 1115384400,
1115388000, 1115391600, 1115395200, 1115398800, 1115402400,
1115406000, 1115409600, 1115413200, 1115416800, 1115420400,
1115424000, 1115427600, 1115431200, 1115434800, 1115438400,
1115442000, 1115445600, 1115449200, 1115452800, 1115456400,
1115460000, 1115463600, 1115467200, 1115470800, 1115474400,
1115478000, 1115481600, 1115485200, 1115488800, 1115492400,
1115496000, 1115499600, 1115503200, 1115506800), class = c("POSIXct",
"POSIXt"), tzone = "UTC"), day_mean = c(3496.91666666667,
3496.91666666667, 3496.91666666667, 3496.91666666667, 3496.91666666667,
3496.91666666667, 3496.91666666667, 3496.91666666667, 3496.91666666667,
3496.91666666667, 3496.91666666667, 3496.91666666667, 3496.91666666667,
3496.91666666667, 3496.91666666667, 3496.91666666667, 3496.91666666667,
3496.91666666667, 3496.91666666667, 3496.91666666667, 3496.91666666667,
3496.91666666667, 3496.91666666667, 3496.91666666667, 3480.16666666667,
3480.16666666667, 3480.16666666667, 3480.16666666667, 3480.16666666667,
3480.16666666667, 3480.16666666667, 3480.16666666667, 3480.16666666667,
3480.16666666667, 3480.16666666667, 3480.16666666667, 3480.16666666667,
3480.16666666667, 3480.16666666667, 3480.16666666667, 3480.16666666667,
3480.16666666667, 3480.16666666667, 3480.16666666667, 3480.16666666667,
3480.16666666667, 3480.16666666667, 3480.16666666667, 3351.91666666667,
3351.91666666667, 3351.91666666667, 3351.91666666667, 3351.91666666667,
3351.91666666667, 3351.91666666667, 3351.91666666667, 3351.91666666667,
3351.91666666667, 3351.91666666667, 3351.91666666667, 3351.91666666667,
3351.91666666667, 3351.91666666667, 3351.91666666667, 3351.91666666667,
3351.91666666667, 3351.91666666667, 3351.91666666667, 3351.91666666667,
3351.91666666667, 3351.91666666667, 3351.91666666667, 3382.5,
3382.5, 3382.5, 3382.5, 3382.5, 3382.5, 3382.5, 3382.5, 3382.5,
3382.5, 3382.5, 3382.5, 3382.5, 3382.5, 3382.5, 3382.5, 3382.5,
3382.5, 3382.5, 3382.5, 3382.5, 3382.5, 3382.5, 3382.5, 3464,
3464, 3464, 3464, 3464, 3464, 3464, 3464, 3464, 3464, 3464,
3464, 3464, 3464, 3464, 3464, 3464, 3464, 3464, 3464, 3464,
3464, 3464, 3464, 2859.41666666667, 2859.41666666667, 2859.41666666667,
2859.41666666667, 2859.41666666667, 2859.41666666667, 2859.41666666667,
2859.41666666667, 2859.41666666667, 2859.41666666667, 2859.41666666667,
2859.41666666667, 2859.41666666667, 2859.41666666667, 2859.41666666667,
2859.41666666667, 2859.41666666667, 2859.41666666667, 2859.41666666667,
2859.41666666667, 2859.41666666667, 2859.41666666667, 2859.41666666667,
2859.41666666667, 2348.5, 2348.5, 2348.5, 2348.5, 2348.5,
2348.5, 2348.5, 2348.5, 2348.5, 2348.5, 2348.5, 2348.5, 2348.5,
2348.5, 2348.5, 2348.5, 2348.5, 2348.5, 2348.5, 2348.5, 2348.5,
2348.5, 2348.5, 2348.5), day_min = c(1019L, 1019L, 1019L,
1019L, 1019L, 1019L, 1019L, 1019L, 1019L, 1019L, 1019L, 1019L,
1019L, 1019L, 1019L, 1019L, 1019L, 1019L, 1019L, 1019L, 1019L,
1019L, 1019L, 1019L, 656L, 656L, 656L, 656L, 656L, 656L,
656L, 656L, 656L, 656L, 656L, 656L, 656L, 656L, 656L, 656L,
656L, 656L, 656L, 656L, 656L, 656L, 656L, 656L, 593L, 593L,
593L, 593L, 593L, 593L, 593L, 593L, 593L, 593L, 593L, 593L,
593L, 593L, 593L, 593L, 593L, 593L, 593L, 593L, 593L, 593L,
593L, 593L, 634L, 634L, 634L, 634L, 634L, 634L, 634L, 634L,
634L, 634L, 634L, 634L, 634L, 634L, 634L, 634L, 634L, 634L,
634L, 634L, 634L, 634L, 634L, 634L, 539L, 539L, 539L, 539L,
539L, 539L, 539L, 539L, 539L, 539L, 539L, 539L, 539L, 539L,
539L, 539L, 539L, 539L, 539L, 539L, 539L, 539L, 539L, 539L,
1177L, 1177L, 1177L, 1177L, 1177L, 1177L, 1177L, 1177L, 1177L,
1177L, 1177L, 1177L, 1177L, 1177L, 1177L, 1177L, 1177L, 1177L,
1177L, 1177L, 1177L, 1177L, 1177L, 1177L, 712L, 712L, 712L,
712L, 712L, 712L, 712L, 712L, 712L, 712L, 712L, 712L, 712L,
712L, 712L, 712L, 712L, 712L, 712L, 712L, 712L, 712L, 712L,
712L), day_max = c(5931L, 5931L, 5931L, 5931L, 5931L, 5931L,
5931L, 5931L, 5931L, 5931L, 5931L, 5931L, 5931L, 5931L, 5931L,
5931L, 5931L, 5931L, 5931L, 5931L, 5931L, 5931L, 5931L, 5931L,
6183L, 6183L, 6183L, 6183L, 6183L, 6183L, 6183L, 6183L, 6183L,
6183L, 6183L, 6183L, 6183L, 6183L, 6183L, 6183L, 6183L, 6183L,
6183L, 6183L, 6183L, 6183L, 6183L, 6183L, 6229L, 6229L, 6229L,
6229L, 6229L, 6229L, 6229L, 6229L, 6229L, 6229L, 6229L, 6229L,
6229L, 6229L, 6229L, 6229L, 6229L, 6229L, 6229L, 6229L, 6229L,
6229L, 6229L, 6229L, 6169L, 6169L, 6169L, 6169L, 6169L, 6169L,
6169L, 6169L, 6169L, 6169L, 6169L, 6169L, 6169L, 6169L, 6169L,
6169L, 6169L, 6169L, 6169L, 6169L, 6169L, 6169L, 6169L, 6169L,
6064L, 6064L, 6064L, 6064L, 6064L, 6064L, 6064L, 6064L, 6064L,
6064L, 6064L, 6064L, 6064L, 6064L, 6064L, 6064L, 6064L, 6064L,
6064L, 6064L, 6064L, 6064L, 6064L, 6064L, 5618L, 5618L, 5618L,
5618L, 5618L, 5618L, 5618L, 5618L, 5618L, 5618L, 5618L, 5618L,
5618L, 5618L, 5618L, 5618L, 5618L, 5618L, 5618L, 5618L, 5618L,
5618L, 5618L, 5618L, 3606L, 3606L, 3606L, 3606L, 3606L, 3606L,
3606L, 3606L, 3606L, 3606L, 3606L, 3606L, 3606L, 3606L, 3606L,
3606L, 3606L, 3606L, 3606L, 3606L, 3606L, 3606L, 3606L, 3606L
)), .Names = c("kvish", "keta", "maslul", "yom", "nefah",
"date", "day_mean", "day_min", "day_max"), row.names = c(NA,
-168L), class = "data.frame"), X2006_kvish_1_10t = structure(list(
kvish = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L), keta = c(10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L), maslul = c(1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L
), yom = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L), nefah = c(2408L, 1539L, 1114L, 990L,
851L, 1059L, 2293L, 3963L, 3954L, 3370L, 3182L, 3395L, 3637L,
3979L, 4506L, 5642L, 5990L, 5962L, 6096L, 5650L, 4668L, 3312L,
2582L, 2409L, 1831L, 1091L, 816L, 816L, 775L, 1029L, 2387L,
4077L, 4044L, 3311L, 3247L, 3278L, 3935L, 4131L, 4556L, 5879L,
6072L, 6206L, 6391L, 5841L, 5234L, 3582L, 2702L, 2673L, 1825L,
1210L, 904L, 763L, 748L, 961L, 2312L, 3831L, 4186L, 3198L,
3293L, 3452L, 3946L, 4308L, 4898L, 5915L, 5932L, 5722L, 5929L,
5762L, 5515L, 3841L, 2833L, 2785L, 2282L, 1367L, 976L, 914L,
781L, 962L, 2287L, 3990L, 3806L, 3420L, 3294L, 3578L, 4026L,
4212L, 4883L, 5924L, 6104L, 6080L, 5967L, 5953L, 5172L, 3471L,
2991L, 2686L, 2001L, 1317L, 999L, 848L, 681L, 947L, 2215L,
4015L, 4047L, 3378L, 3309L, 3599L, 3838L, 4737L, 5051L, 5933L,
5941L, 6131L, 5550L, 5910L, 4461L, 3833L, 2801L, 2920L, 2888L,
2106L, 1958L, 1798L, 1464L, 1144L, 1409L, 1907L, 2262L, 2566L,
3007L, 3981L, 4919L, 4904L, 4547L, 4347L, 4299L, 3994L, 3574L,
3633L, 2225L, 1961L, 2408L, 2183L, 1998L, 1851L, 1795L, 1759L,
1462L, 1144L, 866L, 665L, 800L, 1210L, 1610L, 2088L, 2528L,
2658L, 2441L, 2627L, 2933L, 3410L, 3397L, 3845L, 3268L, 3972L,
3812L, 3858L), date = structure(c(1157241600, 1157245200,
1157248800, 1157252400, 1157256000, 1157259600, 1157263200,
1157266800, 1157270400, 1157274000, 1157277600, 1157281200,
1157284800, 1157288400, 1157292000, 1157295600, 1157299200,
1157302800, 1157306400, 1157310000, 1157313600, 1157317200,
1157320800, 1157324400, 1157328000, 1157331600, 1157335200,
1157338800, 1157342400, 1157346000, 1157349600, 1157353200,
1157356800, 1157360400, 1157364000, 1157367600, 1157371200,
1157374800, 1157378400, 1157382000, 1157385600, 1157389200,
1157392800, 1157396400, 1157400000, 1157403600, 1157407200,
1157410800, 1157414400, 1157418000, 1157421600, 1157425200,
1157428800, 1157432400, 1157436000, 1157439600, 1157443200,
1157446800, 1157450400, 1157454000, 1157457600, 1157461200,
1157464800, 1157468400, 1157472000, 1157475600, 1157479200,
1157482800, 1157486400, 1157490000, 1157493600, 1157497200,
1157500800, 1157504400, 1157508000, 1157511600, 1157515200,
1157518800, 1157522400, 1157526000, 1157529600, 1157533200,
1157536800, 1157540400, 1157544000, 1157547600, 1157551200,
1157554800, 1157558400, 1157562000, 1157565600, 1157569200,
1157572800, 1157576400, 1157580000, 1157583600, 1157587200,
1157590800, 1157594400, 1157598000, 1157601600, 1157605200,
1157608800, 1157612400, 1157616000, 1157619600, 1157623200,
1157626800, 1157630400, 1157634000, 1157637600, 1157641200,
1157644800, 1157648400, 1157652000, 1157655600, 1157659200,
1157662800, 1157666400, 1157670000, 1157673600, 1157677200,
1157680800, 1157684400, 1157688000, 1157691600, 1157695200,
1157698800, 1157702400, 1157706000, 1157709600, 1157713200,
1157716800, 1157720400, 1157724000, 1157727600, 1157731200,
1157734800, 1157738400, 1157742000, 1157745600, 1157749200,
1157752800, 1157756400, 1157760000, 1157763600, 1157767200,
1157770800, 1157774400, 1157778000, 1157781600, 1157785200,
1157788800, 1157792400, 1157796000, 1157799600, 1157803200,
1157806800, 1157810400, 1157814000, 1157817600, 1157821200,
1157824800, 1157828400, 1157832000, 1157835600, 1157839200,
1157842800), class = c("POSIXct", "POSIXt"), tzone = "UTC"),
day_mean = c(3439.625, 3439.625, 3439.625, 3439.625, 3439.625,
3439.625, 3439.625, 3439.625, 3439.625, 3439.625, 3439.625,
3439.625, 3439.625, 3439.625, 3439.625, 3439.625, 3439.625,
3439.625, 3439.625, 3439.625, 3439.625, 3439.625, 3439.625,
3439.625, 3496, 3496, 3496, 3496, 3496, 3496, 3496, 3496,
3496, 3496, 3496, 3496, 3496, 3496, 3496, 3496, 3496, 3496,
3496, 3496, 3496, 3496, 3496, 3496, 3502.875, 3502.875, 3502.875,
3502.875, 3502.875, 3502.875, 3502.875, 3502.875, 3502.875,
3502.875, 3502.875, 3502.875, 3502.875, 3502.875, 3502.875,
3502.875, 3502.875, 3502.875, 3502.875, 3502.875, 3502.875,
3502.875, 3502.875, 3502.875, 3546.91666666667, 3546.91666666667,
3546.91666666667, 3546.91666666667, 3546.91666666667, 3546.91666666667,
3546.91666666667, 3546.91666666667, 3546.91666666667, 3546.91666666667,
3546.91666666667, 3546.91666666667, 3546.91666666667, 3546.91666666667,
3546.91666666667, 3546.91666666667, 3546.91666666667, 3546.91666666667,
3546.91666666667, 3546.91666666667, 3546.91666666667, 3546.91666666667,
3546.91666666667, 3546.91666666667, 3519.25, 3519.25, 3519.25,
3519.25, 3519.25, 3519.25, 3519.25, 3519.25, 3519.25, 3519.25,
3519.25, 3519.25, 3519.25, 3519.25, 3519.25, 3519.25, 3519.25,
3519.25, 3519.25, 3519.25, 3519.25, 3519.25, 3519.25, 3519.25,
2895.16666666667, 2895.16666666667, 2895.16666666667, 2895.16666666667,
2895.16666666667, 2895.16666666667, 2895.16666666667, 2895.16666666667,
2895.16666666667, 2895.16666666667, 2895.16666666667, 2895.16666666667,
2895.16666666667, 2895.16666666667, 2895.16666666667, 2895.16666666667,
2895.16666666667, 2895.16666666667, 2895.16666666667, 2895.16666666667,
2895.16666666667, 2895.16666666667, 2895.16666666667, 2895.16666666667,
2333.20833333333, 2333.20833333333, 2333.20833333333, 2333.20833333333,
2333.20833333333, 2333.20833333333, 2333.20833333333, 2333.20833333333,
2333.20833333333, 2333.20833333333, 2333.20833333333, 2333.20833333333,
2333.20833333333, 2333.20833333333, 2333.20833333333, 2333.20833333333,
2333.20833333333, 2333.20833333333, 2333.20833333333, 2333.20833333333,
2333.20833333333, 2333.20833333333, 2333.20833333333, 2333.20833333333
), day_min = c(851L, 851L, 851L, 851L, 851L, 851L, 851L,
851L, 851L, 851L, 851L, 851L, 851L, 851L, 851L, 851L, 851L,
851L, 851L, 851L, 851L, 851L, 851L, 851L, 775L, 775L, 775L,
775L, 775L, 775L, 775L, 775L, 775L, 775L, 775L, 775L, 775L,
775L, 775L, 775L, 775L, 775L, 775L, 775L, 775L, 775L, 775L,
775L, 748L, 748L, 748L, 748L, 748L, 748L, 748L, 748L, 748L,
748L, 748L, 748L, 748L, 748L, 748L, 748L, 748L, 748L, 748L,
748L, 748L, 748L, 748L, 748L, 781L, 781L, 781L, 781L, 781L,
781L, 781L, 781L, 781L, 781L, 781L, 781L, 781L, 781L, 781L,
781L, 781L, 781L, 781L, 781L, 781L, 781L, 781L, 781L, 681L,
681L, 681L, 681L, 681L, 681L, 681L, 681L, 681L, 681L, 681L,
681L, 681L, 681L, 681L, 681L, 681L, 681L, 681L, 681L, 681L,
681L, 681L, 681L, 1144L, 1144L, 1144L, 1144L, 1144L, 1144L,
1144L, 1144L, 1144L, 1144L, 1144L, 1144L, 1144L, 1144L, 1144L,
1144L, 1144L, 1144L, 1144L, 1144L, 1144L, 1144L, 1144L, 1144L,
665L, 665L, 665L, 665L, 665L, 665L, 665L, 665L, 665L, 665L,
665L, 665L, 665L, 665L, 665L, 665L, 665L, 665L, 665L, 665L,
665L, 665L, 665L, 665L), day_max = c(6096L, 6096L, 6096L,
6096L, 6096L, 6096L, 6096L, 6096L, 6096L, 6096L, 6096L, 6096L,
6096L, 6096L, 6096L, 6096L, 6096L, 6096L, 6096L, 6096L, 6096L,
6096L, 6096L, 6096L, 6391L, 6391L, 6391L, 6391L, 6391L, 6391L,
6391L, 6391L, 6391L, 6391L, 6391L, 6391L, 6391L, 6391L, 6391L,
6391L, 6391L, 6391L, 6391L, 6391L, 6391L, 6391L, 6391L, 6391L,
5932L, 5932L, 5932L, 5932L, 5932L, 5932L, 5932L, 5932L, 5932L,
5932L, 5932L, 5932L, 5932L, 5932L, 5932L, 5932L, 5932L, 5932L,
5932L, 5932L, 5932L, 5932L, 5932L, 5932L, 6104L, 6104L, 6104L,
6104L, 6104L, 6104L, 6104L, 6104L, 6104L, 6104L, 6104L, 6104L,
6104L, 6104L, 6104L, 6104L, 6104L, 6104L, 6104L, 6104L, 6104L,
6104L, 6104L, 6104L, 6131L, 6131L, 6131L, 6131L, 6131L, 6131L,
6131L, 6131L, 6131L, 6131L, 6131L, 6131L, 6131L, 6131L, 6131L,
6131L, 6131L, 6131L, 6131L, 6131L, 6131L, 6131L, 6131L, 6131L,
4919L, 4919L, 4919L, 4919L, 4919L, 4919L, 4919L, 4919L, 4919L,
4919L, 4919L, 4919L, 4919L, 4919L, 4919L, 4919L, 4919L, 4919L,
4919L, 4919L, 4919L, 4919L, 4919L, 4919L, 3972L, 3972L, 3972L,
3972L, 3972L, 3972L, 3972L, 3972L, 3972L, 3972L, 3972L, 3972L,
3972L, 3972L, 3972L, 3972L, 3972L, 3972L, 3972L, 3972L, 3972L,
3972L, 3972L, 3972L)), .Names = c("kvish", "keta", "maslul",
"yom", "nefah", "date", "day_mean", "day_min", "day_max"), row.names = c(NA,
-168L), class = "data.frame")), .Names = c("X2005_kvish_1_10t",
"X2006_kvish_1_10t"))
&#13;
答案 0 :(得分:0)
使用Parfait的示例数据集dfList
,您可以执行以下操作。
func <- function(X, cols, rows = cc){
X[rows, cols] <- NA
X
}
newList <- lapply(dfList, func, cols = 3:4)
newList
您现在可以更改cols
参数并传递您需要更改的列。在上面的示例中,这些列为3:4
,在您的原始帖子中为8:10
。对于行索引cc
,它是参数rows
的默认值,因此您可以保持不变。
使用您提供的数据集,上述工作,将列表名称更改为kvish_1_10t.tables
,以及列号。请注意,当8:10
data.frames
只有9列时,您的原始帖子会提到kvish_1_10t.tables
列。
newList <- lapply(kvish_1_10t.tables, func, cols = 8:9)
str(newList)
List of 2
$ X2005_kvish_1_10t:'data.frame': 168 obs. of 9 variables:
..$ kvish : int [1:168] 1 1 1 1 1 1 1 1 1 1 ...
..$ keta : int [1:168] 10 10 10 10 10 10 10 10 10 10 ...
..$ maslul : int [1:168] 1 1 1 1 1 1 1 1 1 1 ...
..$ yom : int [1:168] 1 1 1 1 1 1 1 1 1 1 ...
..$ nefah : int [1:168] 2743 1759 1227 1077 1019 1181 2440 4257 4034 3539 ...
..$ date : POSIXct[1:168], format: "2005-05-01 00:00:00" "2005-05-01 01:00:00" ...
..$ day_mean: num [1:168] 3497 3497 3497 3497 3497 ...
..$ day_min : int [1:168] 1019 NA NA NA NA NA NA NA NA NA ...
..$ day_max : int [1:168] 5931 NA NA NA NA NA NA NA NA NA ...
$ X2006_kvish_1_10t:'data.frame': 168 obs. of 9 variables:
..$ kvish : int [1:168] 1 1 1 1 1 1 1 1 1 1 ...
..$ keta : int [1:168] 10 10 10 10 10 10 10 10 10 10 ...
..$ maslul : int [1:168] 1 1 1 1 1 1 1 1 1 1 ...
..$ yom : int [1:168] 1 1 1 1 1 1 1 1 1 1 ...
..$ nefah : int [1:168] 2408 1539 1114 990 851 1059 2293 3963 3954 3370 ...
..$ date : POSIXct[1:168], format: "2006-09-03 00:00:00" "2006-09-03 01:00:00" ...
..$ day_mean: num [1:168] 3440 3440 3440 3440 3440 ...
..$ day_min : int [1:168] 851 NA NA NA NA NA NA NA NA NA ...
..$ day_max : int [1:168] 6096 NA NA NA NA NA NA NA NA NA ...