Here is my data;
ht<-structure(list(`1-2006` = structure(c(1.6, 1.6, 1.6, 1.6, 0.208,
0.405, 0.527, 0.818, 2.2, 3, 2.2, 3, 3, 3, 3, 3.2, 4.6, 5.2), .Names = c("nmaxm5",
"nmaxm10", "nmaxm15", "nmaxm30", "dmaxm5", "dmaxm10", "dmaxm15",
"dmaxm30", "maxhourly", "maxh2", "maxh3", "maxh4", "maxh5", "maxh6",
"maxh8", "maxh12", "maxh18", "maxdaily")), `1-2007` = structure(c(0.8,
1.4, 2, 3, 2.345, 4.085, 4.884, 4.884, 3.8, 5.2, 5.2, 5.6, 5.6,
5.6, 5.6, 5.6, 5.6, 5.6), .Names = c("nmaxm5", "nmaxm10", "nmaxm15",
"nmaxm30", "dmaxm5", "dmaxm10", "dmaxm15", "dmaxm30", "maxhourly",
"maxh2", "maxh3", "maxh4", "maxh5", "maxh6", "maxh8", "maxh12",
"maxh18", "maxdaily")), `2-2006` = structure(c(0.8, 1, 1, 1.2,
0.232, 0.464, 0.691, 1.32, 2.2, 3.2, 4.4, 4.2, 5.8, 5, 6.8, 7.6,
9, 8.8), .Names = c("nmaxm5", "nmaxm10", "nmaxm15", "nmaxm30",
"dmaxm5", "dmaxm10", "dmaxm15", "dmaxm30", "maxhourly", "maxh2",
"maxh3", "maxh4", "maxh5", "maxh6", "maxh8", "maxh12", "maxh18",
"maxdaily")), `2-2007` = structure(c(0.4, 0.6, 0.8, 1.2, 0.643,
1.218, 1.577, 3.128, 1.8, 2.4, 2.4, 3.8, 3.8, 3, 3.8, 3.8, 3.8,
4), .Names = c("nmaxm5", "nmaxm10", "nmaxm15", "nmaxm30", "dmaxm5",
"dmaxm10", "dmaxm15", "dmaxm30", "maxhourly", "maxh2", "maxh3",
"maxh4", "maxh5", "maxh6", "maxh8", "maxh12", "maxh18", "maxdaily"
)), `3-2006` = structure(c(1.6, 3.2, 2.6, 4.4, 0.575, 0.947,
1.306, 2.184, 4.4, 5.4, 8.6, 7.2, 7.4, 8.8, 8, 8.8, 11.2, 13.8
), .Names = c("nmaxm5", "nmaxm10", "nmaxm15", "nmaxm30", "dmaxm5",
"dmaxm10", "dmaxm15", "dmaxm30", "maxhourly", "maxh2", "maxh3",
"maxh4", "maxh5", "maxh6", "maxh8", "maxh12", "maxh18", "maxdaily"
)), `3-2007` = structure(c(0.6, 0.8, 1.2, 2, 0.62, 1.239, 1.859,
3.34, 3.8, 5.6, 8.2, 9.2, 10.2, 9.8, 9.8, 9.8, 11.2, 13.6), .Names = c("nmaxm5",
"nmaxm10", "nmaxm15", "nmaxm30", "dmaxm5", "dmaxm10", "dmaxm15",
"dmaxm30", "maxhourly", "maxh2", "maxh3", "maxh4", "maxh5", "maxh6",
"maxh8", "maxh12", "maxh18", "maxdaily"))), .Names = c("1-2006",
"1-2007", "2-2006", "2-2007", "3-2006", "3-2007"))
As you can see, I have 6 elements in the list.1-2006, 1-2007, 2-2006, 2-2007, 3-2006, 3-2007
I want to find maxima of each row for 1-2006, 2-2006, 3-2006
, also for 1-2007, 2-2007, 3-2007
.
Finally I will get;
2006
nmax5 1.6 (the max. value between `1-2006, 2-2006, 3-2006`)
nmax10 3.2 (the max. value between `1-2006, 2-2006, 3-2006`)
nmax15 2.6 .
. .
.
.
2007
nmax5 0.8
nmax10 1.4
nmax15 2
.
.
.
Addition to question
What If each data (1-2006, 1-2007...) is a list like below;
data<-structure(list(`1-2006` = structure(list(max = structure(c(1.6,
1.6, 1.6, 1.6, 0.208, 0.405, 0.527, 0.818, 2.2, 3, 2.2, 3, 3,
3, 3, 3.2, 4.6, 5.2), .Names = c("nmaxm5", "nmaxm10", "nmaxm15",
"nmaxm30", "dmaxm5", "dmaxm10", "dmaxm15", "dmaxm30", "maxhourly",
"maxh2", "maxh3", "maxh4", "maxh5", "maxh6", "maxh8", "maxh12",
"maxh18", "maxdaily")), pars = structure(c(4.31546117106427,
0.820365947190018, 0.0801520102681417, 1.23559346429995, 0.165928116911697,
4.9018542025384), .Names = c("a", "l", "v", "k", "f", "mx")),
stats = structure(list(mean1 = 0.0351706036745407, mean6 = 0.209375,
mean12 = 0.41875, mean24 = 0.8375, var1 = 0.0274966155546346,
var6 = 0.301498015873016, var12 = 0.749314516129032,
var24 = 2.0385, pdr1 = 0.921259842519685, pdr6 = 0.71875,
pdr12 = 0.625, pdr24 = 0.375, cov1lag1 = 0.00862854839737093,
cov6lag1 = 0.112977142333984, cov12lag1 = 0.296668701171875,
cov24lag1 = 0.234755859375), .Names = c("mean1", "mean6",
"mean12", "mean24", "var1", "var6", "var12", "var24", "pdr1",
"pdr6", "pdr12", "pdr24", "cov1lag1", "cov6lag1", "cov12lag1",
"cov24lag1")), dismax = c(0.208, 0.405, 0.527, 0.818), normax = c(1.6,
1.6, 1.6, 1.6), corr = NA_real_), .Names = c("max", "pars",
"stats", "dismax", "normax", "corr")), `1-2007` = structure(list(
max = structure(c(0.8, 1.4, 2, 3, 2.345, 4.085, 4.884, 4.884,
3.8, 5.2, 5.2, 5.6, 5.6, 5.6, 5.6, 5.6, 5.6, 5.6), .Names = c("nmaxm5",
"nmaxm10", "nmaxm15", "nmaxm30", "dmaxm5", "dmaxm10", "dmaxm15",
"dmaxm30", "maxhourly", "maxh2", "maxh3", "maxh4", "maxh5",
"maxh6", "maxh8", "maxh12", "maxh18", "maxdaily")), pars = structure(c(9.43730555970531,
0.355744546440369, 0.0141306464171967, 2.50913042364416,
0.368250713406274, 92.0687563990534), .Names = c("a", "l",
"v", "k", "f", "mx")), stats = structure(list(mean1 = 0.0186770428015564,
mean6 = 0.111627906976744, mean12 = 0.223255813953488,
mean24 = 0.436363636363636, var1 = 0.0359857707389962,
var6 = 0.390216142270862, var12 = 0.800398671096346,
var24 = 1.5795670995671, pdr1 = 0.972762645914397, pdr6 = 0.895348837209302,
pdr12 = 0.86046511627907, pdr24 = 0.772727272727273,
cov1lag1 = 0.0103119680100725, cov6lag1 = 0.00320827096985171,
cov12lag1 = -0.0323976505213377, cov24lag1 = -0.199068369646882), .Names = c("mean1",
"mean6", "mean12", "mean24", "var1", "var6", "var12", "var24",
"pdr1", "pdr6", "pdr12", "pdr24", "cov1lag1", "cov6lag1",
"cov12lag1", "cov24lag1")), dismax = c(2.345, 4.085, 4.884,
4.884), normax = c(0.8, 1.4, 2, 3), corr = 0.848495355933634), .Names = c("max",
"pars", "stats", "dismax", "normax", "corr"))), .Names = c("1-2006",
"1-2007"))
How can I pick the max
section for each data (1-2006, 1-2007) instead of ht
in the code below?
lapply(split(ht, sub("^\\d+-", "", names(ht))), function(x)
apply(do.call(rbind, x), 2, max))