I have many files that are all similar in formatting to the dataset given below. For each of these files I have to do some calculations, starting with an offset correction. I have loaded these files into a list as data.frames, And would like to do the following modification for each file in the list:
data = SD07_TWK_20190822_003004
test = data
colnames = c(paste0('t', 1:8))
colmeans = colMeans(data[1:5,colnames]) #Calculates the mean of the given columns
testcorr = t(t(data[, paste0('t', 1:8)]) - colmeans) #substracts the means from these columns
test[,colnames] = testcorr #adds the new columns to the dataset
The calculation amounts to taking the mean of the first 5 rows of column t1-t8 and substracting this mean from the entire column. To do this for each file in my entire list I have tried the following:
for(i in totaldata){
colmeans = colMeans(i[1:5,colnames])
i = t(t(i[, paste0('t', 1:8)]) - colmeans)}
But that doesn't seem to work, And I don't really have a good idea of what I'm doing. Even if you don't have a direct solution, some pointers will also be of great help!
A part of the list of data: The first data.frame is the one used in the original calculation
> dput(totaldata[1:2])
list(structure(list(time = c(2, 3.9, 5.8, 7.8, 9.7, 11.7, 13.6,
15.5, 17.5, 19.4, 21.4, 23.3, 25.3, 27.2, 29.2, 31.2, 33.1, 35.1,
37.1, 39, 41, 42.9, 44.9, 46.8, 48.7, 50.7, 52.6, 54.6, 56.5,
58.5, 60.4, 62.4, 64.3, 66.2, 68.2, 70.1, 72.1, 74, 76, 77.9,
79.8, 81.8, 83.7, 85.7, 87.6, 89.5, 91.5, 93.4, 95.4, 97.3, 99.3,
101.2, 103.1, 105.1, 107, 109, 110.9, 112.8, 114.8, 116.7, 118.7,
120.6, 122.5, 124.5, 126.4, 128.4, 130.3, 132.2, 134.2, 136.1,
138.1, 140, 141.9, 143.9, 145.8, 147.8, 149.7, 151.6, 153.6,
155.5, 157.5, 159.4, 161.3, 163.3, 165.2, 167.2, 169.1, 171,
173, 174.9, 176.9, 178.8, 180.7, 182.7, 184.6, 186.6, 188.5,
190.4, 192.4, 194.3, 196.3, 198.2, 200.1, 202.1, 204, 206, 207.9,
209.8, 211.8, 213.7, 215.7, 217.6, 219.5, 221.5, 223.4, 225.4,
227.3, 229.3, 231.2, 233.1, 235.1, 237, 239, 240.9, 242.8, 244.8,
246.7, 248.7, 250.6, 252.5, 254.5, 256.4, 258.4, 260.3, 262.2,
264.2, 266.1, 268.1, 270, 271.9, 273.9, 275.8, 277.8, 279.7,
281.6, 283.6, 285.5, 287.5, 289.4, 291.3, 293.3, 295.2, 297.2,
299.1, 301), v = c(14.82, 14.804, 14.82, 14.82, 14.804, 14.82,
14.812, 14.804, 14.8, 14.808, 14.8, 14.804, 15.844, 15.848, 15.848,
15.852, 15.852, 15.848, 15.852, 15.852, 15.852, 15.852, 15.856,
15.852, 15.852, 15.856, 15.856, 15.856, 15.856, 15.856, 15.856,
15.856, 15.852, 15.852, 15.852, 15.852, 15.856, 15.856, 15.856,
15.86, 15.856, 15.86, 15.864, 15.856, 15.86, 15.86, 15.86, 15.856,
15.86, 15.856, 15.86, 15.86, 15.856, 15.856, 15.86, 15.86, 15.86,
15.86, 15.864, 15.86, 15.86, 15.86, 15.86, 15.86, 15.856, 15.856,
15.856, 15.856, 15.856, 15.86, 15.86, 15.86, 15.856, 15.864,
15.86, 15.86, 15.86, 15.86, 15.86, 15.86, 15.856, 15.856, 15.86,
15.86, 15.864, 15.86, 15.86, 15.86, 15.864, 15.86, 15.86, 15.86,
15.86, 15.86, 15.86, 15.86, 15.86, 15.86, 15.86, 15.86, 15.86,
15.86, 15.86, 15.86, 15.86, 15.86, 15.86, 15.86, 15.856, 15.86,
15.86, 15.856, 15.86, 15.86, 15.86, 15.864, 15.86, 15.86, 15.86,
15.856, 15.86, 15.856, 15.86, 15.86, 15.86, 15.856, 15.86, 15.86,
15.86, 15.86, 15.86, 15.86, 15.856, 15.86, 15.856, 15.86, 15.856,
15.86, 15.856, 15.86, 15.86, 15.864, 15.86, 15.86, 15.86, 15.86,
15.86, 15.86, 15.856, 15.86, 15.86, 15.86, 15.856, 15.86, 15.86
), a = c(1.5, 1.476, 1.5, 1.491, 1.452, 1.476, 1.478, 1.44, 1.454,
1.438, 1.442, 1.471, 0.002, 0.002, 0.002, 0.002, 0.002, 0.002,
0.002, 0.002, 0.001, 0.002, 0.002, 0.001, 0.001, 0.002, 0.002,
0.002, 0.001, 0.001, 0.001, 0.002, 0.002, 0.002, 0.001, 0.002,
0.002, 0.002, 0.001, 0.002, 0.002, 0.002, 0.002, 0.002, 0.001,
0.002, 0.002, 0.002, 0.001, 0.002, 0.001, 0.001, 0.001, 0.002,
0.002, 0.001, 0.002, 0.001, 0.002, 0.002, 0.002, 0.002, 0.002,
0.002, 0.002, 0.002, 0.002, 0.001, 0.002, 0.001, 0.002, 0.001,
0.001, 0.002, 0.002, 0.002, 0.002, 0.001, 0.002, 0.001, 0.002,
0.002, 0.001, 0.002, 0.002, 0.002, 0.002, 0.001, 0.002, 0.002,
0.001, 0.002, 0.002, 0.002, 0.002, 0.002, 0.001, 0.001, 0.002,
0.001, 0.002, 0.002, 0.002, 0.002, 0.001, 0.002, 0.001, 0.002,
0.002, 0.002, 0.001, 0.001, 0.002, 0.002, 0.002, 0.001, 0.002,
0.001, 0.002, 0.002, 0.001, 0.002, 0.001, 0.002, 0.002, 0.002,
0.002, 0.002, 0.002, 0.002, 0.001, 0.002, 0.002, 0.001, 0.002,
0.002, 0.002, 0.002, 0.002, 0.001, 0.002, 0.002, 0.001, 0.002,
0.002, 0.002, 0.002, 0.002, 0.002, 0.002, 0.002, 0.001, 0.002,
0.002, 0.002), t1 = c(14.61, 14.61, 14.61, 14.61, 14.61, 14.61,
14.61, 14.62, 14.62, 14.63, 14.64, 14.65, 14.67, 14.7, 14.72,
14.75, 14.78, 14.82, 14.85, 14.89, 14.93, 14.97, 15.01, 15.05,
15.09, 15.13, 15.17, 15.2, 15.23, 15.26, 15.29, 15.32, 15.34,
15.37, 15.39, 15.41, 15.43, 15.45, 15.46, 15.48, 15.49, 15.51,
15.52, 15.53, 15.54, 15.55, 15.56, 15.56, 15.57, 15.58, 15.58,
15.59, 15.59, 15.6, 15.6, 15.6, 15.61, 15.61, 15.61, 15.61, 15.62,
15.62, 15.62, 15.62, 15.62, 15.62, 15.62, 15.62, 15.62, 15.62,
15.62, 15.62, 15.62, 15.62, 15.62, 15.62, 15.62, 15.62, 15.62,
15.62, 15.62, 15.62, 15.62, 15.62, 15.62, 15.62, 15.61, 15.61,
15.61, 15.61, 15.61, 15.61, 15.61, 15.61, 15.6, 15.6, 15.6, 15.6,
15.6, 15.6, 15.6, 15.59, 15.59, 15.59, 15.59, 15.59, 15.59, 15.58,
15.58, 15.58, 15.58, 15.58, 15.58, 15.58, 15.57, 15.57, 15.57,
15.57, 15.57, 15.56, 15.56, 15.56, 15.56, 15.56, 15.56, 15.55,
15.55, 15.55, 15.55, 15.55, 15.54, 15.54, 15.54, 15.54, 15.54,
15.54, 15.53, 15.53, 15.53, 15.53, 15.53, 15.53, 15.52, 15.52,
15.52, 15.52, 15.52, 15.51, 15.51, 15.51, 15.51, 15.51, 15.51,
15.5, 15.5), t2 = c(14.63, 14.62, 14.62, 14.62, 14.62, 14.62,
14.62, 14.63, 14.63, 14.64, 14.65, 14.67, 14.69, 14.71, 14.74,
14.78, 14.82, 14.86, 14.9, 14.95, 15, 15.06, 15.11, 15.16, 15.22,
15.27, 15.31, 15.36, 15.4, 15.44, 15.48, 15.51, 15.55, 15.58,
15.61, 15.63, 15.65, 15.68, 15.7, 15.71, 15.73, 15.75, 15.76,
15.77, 15.78, 15.79, 15.8, 15.81, 15.82, 15.83, 15.83, 15.84,
15.85, 15.85, 15.85, 15.86, 15.86, 15.87, 15.87, 15.87, 15.87,
15.87, 15.88, 15.88, 15.88, 15.88, 15.88, 15.88, 15.88, 15.88,
15.88, 15.88, 15.88, 15.88, 15.88, 15.88, 15.88, 15.88, 15.87,
15.87, 15.87, 15.87, 15.87, 15.87, 15.87, 15.87, 15.86, 15.86,
15.86, 15.86, 15.86, 15.86, 15.85, 15.85, 15.85, 15.85, 15.85,
15.84, 15.84, 15.84, 15.84, 15.84, 15.83, 15.83, 15.83, 15.83,
15.82, 15.82, 15.82, 15.82, 15.82, 15.81, 15.81, 15.81, 15.81,
15.8, 15.8, 15.8, 15.8, 15.79, 15.79, 15.79, 15.79, 15.78, 15.78,
15.78, 15.78, 15.77, 15.77, 15.77, 15.77, 15.76, 15.76, 15.76,
15.76, 15.75, 15.75, 15.75, 15.75, 15.74, 15.74, 15.74, 15.73,
15.73, 15.73, 15.73, 15.72, 15.72, 15.72, 15.72, 15.71, 15.71,
15.71, 15.71, 15.7), t3 = c(14.63, 14.63, 14.63, 14.63, 14.63,
14.63, 14.63, 14.63, 14.64, 14.65, 14.66, 14.68, 14.7, 14.73,
14.75, 14.79, 14.83, 14.86, 14.91, 14.95, 15, 15.04, 15.09, 15.13,
15.18, 15.22, 15.26, 15.3, 15.33, 15.37, 15.4, 15.43, 15.46,
15.48, 15.5, 15.53, 15.54, 15.56, 15.58, 15.59, 15.61, 15.62,
15.63, 15.64, 15.65, 15.66, 15.67, 15.67, 15.68, 15.69, 15.69,
15.7, 15.7, 15.7, 15.71, 15.71, 15.71, 15.71, 15.72, 15.72, 15.72,
15.72, 15.72, 15.72, 15.72, 15.72, 15.72, 15.72, 15.72, 15.72,
15.72, 15.72, 15.72, 15.72, 15.72, 15.71, 15.71, 15.71, 15.71,
15.71, 15.71, 15.71, 15.71, 15.7, 15.7, 15.7, 15.7, 15.7, 15.7,
15.69, 15.69, 15.69, 15.69, 15.69, 15.68, 15.68, 15.68, 15.68,
15.68, 15.67, 15.67, 15.67, 15.67, 15.67, 15.66, 15.66, 15.66,
15.66, 15.66, 15.65, 15.65, 15.65, 15.65, 15.65, 15.64, 15.64,
15.64, 15.64, 15.64, 15.63, 15.63, 15.63, 15.63, 15.62, 15.62,
15.62, 15.62, 15.62, 15.62, 15.61, 15.61, 15.61, 15.61, 15.6,
15.6, 15.6, 15.6, 15.6, 15.59, 15.59, 15.59, 15.59, 15.58, 15.58,
15.58, 15.58, 15.58, 15.57, 15.57, 15.57, 15.57, 15.57, 15.56,
15.56, 15.56), t4 = c(14.65, 14.65, 14.65, 14.65, 14.64, 14.64,
14.65, 14.65, 14.66, 14.67, 14.68, 14.7, 14.73, 14.75, 14.79,
14.82, 14.86, 14.91, 14.95, 15, 15.05, 15.1, 15.16, 15.21, 15.25,
15.3, 15.35, 15.39, 15.43, 15.46, 15.5, 15.53, 15.56, 15.59,
15.62, 15.64, 15.66, 15.68, 15.7, 15.72, 15.73, 15.75, 15.76,
15.77, 15.78, 15.79, 15.8, 15.81, 15.82, 15.82, 15.83, 15.83,
15.84, 15.84, 15.84, 15.85, 15.85, 15.85, 15.86, 15.86, 15.86,
15.86, 15.86, 15.86, 15.86, 15.86, 15.86, 15.86, 15.86, 15.86,
15.86, 15.86, 15.86, 15.86, 15.86, 15.86, 15.86, 15.86, 15.86,
15.85, 15.85, 15.85, 15.85, 15.85, 15.85, 15.84, 15.84, 15.84,
15.84, 15.84, 15.84, 15.83, 15.83, 15.83, 15.83, 15.83, 15.82,
15.82, 15.82, 15.82, 15.82, 15.81, 15.81, 15.81, 15.81, 15.81,
15.8, 15.8, 15.8, 15.8, 15.79, 15.79, 15.79, 15.79, 15.79, 15.78,
15.78, 15.78, 15.78, 15.77, 15.77, 15.77, 15.77, 15.76, 15.76,
15.76, 15.76, 15.75, 15.75, 15.75, 15.75, 15.74, 15.74, 15.74,
15.74, 15.73, 15.73, 15.73, 15.73, 15.72, 15.72, 15.72, 15.72,
15.71, 15.71, 15.71, 15.71, 15.71, 15.7, 15.7, 15.7, 15.7, 15.69,
15.69, 15.69), t5 = c(14.65, 14.65, 14.65, 14.65, 14.65, 14.65,
14.66, 14.66, 14.67, 14.69, 14.7, 14.73, 14.75, 14.78, 14.81,
14.85, 14.89, 14.93, 14.97, 15.02, 15.06, 15.11, 15.15, 15.2,
15.24, 15.28, 15.32, 15.36, 15.4, 15.43, 15.46, 15.49, 15.52,
15.54, 15.57, 15.59, 15.61, 15.63, 15.64, 15.66, 15.68, 15.69,
15.7, 15.71, 15.72, 15.73, 15.74, 15.75, 15.76, 15.76, 15.77,
15.77, 15.78, 15.78, 15.79, 15.79, 15.79, 15.8, 15.8, 15.8, 15.8,
15.8, 15.8, 15.81, 15.81, 15.81, 15.81, 15.81, 15.81, 15.81,
15.81, 15.81, 15.81, 15.8, 15.8, 15.8, 15.8, 15.8, 15.8, 15.8,
15.8, 15.8, 15.79, 15.79, 15.79, 15.79, 15.79, 15.79, 15.79,
15.78, 15.78, 15.78, 15.78, 15.78, 15.77, 15.77, 15.77, 15.77,
15.77, 15.77, 15.76, 15.76, 15.76, 15.76, 15.75, 15.75, 15.75,
15.75, 15.75, 15.74, 15.74, 15.74, 15.74, 15.74, 15.73, 15.73,
15.73, 15.73, 15.72, 15.72, 15.72, 15.72, 15.72, 15.71, 15.71,
15.71, 15.71, 15.71, 15.7, 15.7, 15.7, 15.7, 15.69, 15.69, 15.69,
15.69, 15.68, 15.68, 15.68, 15.68, 15.68, 15.67, 15.67, 15.67,
15.67, 15.66, 15.66, 15.66, 15.66, 15.66, 15.65, 15.65, 15.65,
15.65, 15.64), t6 = c(14.63, 14.63, 14.63, 14.63, 14.63, 14.63,
14.63, 14.64, 14.65, 14.66, 14.67, 14.69, 14.72, 14.74, 14.77,
14.8, 14.84, 14.88, 14.91, 14.95, 15, 15.04, 15.08, 15.12, 15.16,
15.2, 15.23, 15.27, 15.3, 15.33, 15.36, 15.39, 15.41, 15.44,
15.46, 15.48, 15.5, 15.52, 15.54, 15.55, 15.57, 15.58, 15.59,
15.61, 15.62, 15.63, 15.64, 15.65, 15.65, 15.66, 15.67, 15.67,
15.68, 15.69, 15.69, 15.7, 15.7, 15.7, 15.71, 15.71, 15.71, 15.71,
15.72, 15.72, 15.72, 15.72, 15.72, 15.73, 15.73, 15.73, 15.73,
15.73, 15.73, 15.73, 15.73, 15.73, 15.73, 15.73, 15.73, 15.73,
15.73, 15.73, 15.73, 15.73, 15.73, 15.72, 15.72, 15.72, 15.72,
15.72, 15.72, 15.72, 15.72, 15.72, 15.71, 15.71, 15.71, 15.71,
15.71, 15.71, 15.71, 15.71, 15.7, 15.7, 15.7, 15.7, 15.7, 15.7,
15.69, 15.69, 15.69, 15.69, 15.69, 15.68, 15.68, 15.68, 15.68,
15.68, 15.68, 15.67, 15.67, 15.67, 15.67, 15.67, 15.66, 15.66,
15.66, 15.66, 15.66, 15.65, 15.65, 15.65, 15.65, 15.65, 15.64,
15.64, 15.64, 15.64, 15.64, 15.63, 15.63, 15.63, 15.63, 15.63,
15.62, 15.62, 15.62, 15.62, 15.62, 15.61, 15.61, 15.61, 15.61,
15.61, 15.6), t7 = c(14.64, 14.64, 14.64, 14.64, 14.64, 14.64,
14.64, 14.64, 14.65, 14.66, 14.67, 14.68, 14.7, 14.72, 14.75,
14.77, 14.8, 14.83, 14.86, 14.9, 14.93, 14.97, 15, 15.04, 15.07,
15.11, 15.14, 15.17, 15.21, 15.24, 15.26, 15.29, 15.32, 15.34,
15.36, 15.38, 15.41, 15.42, 15.44, 15.46, 15.47, 15.49, 15.5,
15.52, 15.53, 15.54, 15.55, 15.56, 15.57, 15.58, 15.59, 15.6,
15.61, 15.61, 15.62, 15.62, 15.63, 15.64, 15.64, 15.65, 15.65,
15.65, 15.66, 15.66, 15.66, 15.67, 15.67, 15.67, 15.68, 15.68,
15.68, 15.68, 15.68, 15.68, 15.69, 15.69, 15.69, 15.69, 15.69,
15.69, 15.69, 15.69, 15.69, 15.69, 15.69, 15.69, 15.69, 15.69,
15.69, 15.69, 15.69, 15.69, 15.69, 15.69, 15.69, 15.69, 15.69,
15.69, 15.69, 15.69, 15.69, 15.69, 15.69, 15.69, 15.69, 15.68,
15.68, 15.68, 15.68, 15.68, 15.68, 15.68, 15.68, 15.67, 15.67,
15.67, 15.67, 15.67, 15.67, 15.67, 15.67, 15.66, 15.66, 15.66,
15.66, 15.66, 15.66, 15.65, 15.65, 15.65, 15.65, 15.65, 15.65,
15.64, 15.64, 15.64, 15.64, 15.64, 15.64, 15.63, 15.63, 15.63,
15.63, 15.63, 15.62, 15.62, 15.62, 15.62, 15.62, 15.62, 15.61,
15.61, 15.61, 15.61, 15.61), t8 = c(14.6, 14.6, 14.6, 14.6, 14.6,
14.6, 14.61, 14.61, 14.62, 14.63, 14.64, 14.66, 14.68, 14.71,
14.74, 14.77, 14.8, 14.84, 14.88, 14.92, 14.96, 15, 15.03, 15.07,
15.11, 15.14, 15.17, 15.21, 15.24, 15.26, 15.29, 15.31, 15.34,
15.36, 15.38, 15.39, 15.41, 15.43, 15.44, 15.45, 15.47, 15.48,
15.49, 15.5, 15.51, 15.52, 15.52, 15.53, 15.54, 15.54, 15.55,
15.55, 15.56, 15.56, 15.57, 15.57, 15.57, 15.58, 15.58, 15.58,
15.58, 15.59, 15.59, 15.59, 15.59, 15.59, 15.59, 15.59, 15.59,
15.6, 15.6, 15.6, 15.6, 15.6, 15.6, 15.6, 15.6, 15.6, 15.6, 15.6,
15.59, 15.59, 15.59, 15.59, 15.59, 15.59, 15.59, 15.59, 15.59,
15.59, 15.59, 15.59, 15.58, 15.58, 15.58, 15.58, 15.58, 15.58,
15.58, 15.58, 15.58, 15.57, 15.57, 15.57, 15.57, 15.57, 15.57,
15.57, 15.56, 15.56, 15.56, 15.56, 15.56, 15.56, 15.55, 15.55,
15.55, 15.55, 15.55, 15.55, 15.54, 15.54, 15.54, 15.54, 15.54,
15.54, 15.54, 15.53, 15.53, 15.53, 15.53, 15.53, 15.53, 15.52,
15.52, 15.52, 15.52, 15.52, 15.52, 15.51, 15.51, 15.51, 15.51,
15.51, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.5, 15.49, 15.49,
15.49, 15.49)), class = "data.frame", row.names = c(NA, -155L
)), structure(list(time = c(2, 3.9, 5.9, 7.8, 9.7, 11.7, 13.6,
15.6, 17.5, 19.5, 21.4, 23.4, 25.3, 27.2, 29.2, 31.1, 33, 35,
36.9, 38.9, 40.8, 42.7, 44.7, 46.6, 48.5, 50.5, 52.4, 54.4, 56.3,
58.2, 60.2, 62.2, 64.1, 66.1, 68.1, 70, 72, 73.9, 75.9, 77.8,
79.8, 81.7, 83.7, 85.6, 87.5, 89.5, 91.4, 93.4, 95.3, 97.2, 99.2,
101.1, 103, 105, 106.9, 108.9, 110.8, 112.7, 114.7, 116.6, 118.5,
120.5, 122.4, 124.4, 126.3, 128.2, 130.2, 132.1, 134.1, 136,
137.9, 139.9, 141.8, 143.7, 145.7, 147.6, 149.6, 151.5, 153.4,
155.4, 157.3, 159.3, 161.2, 163.1, 165.1, 167, 169, 170.9, 172.8,
174.8, 176.7, 178.7, 180.6, 182.5, 184.5, 186.4, 188.3, 190.3,
192.2, 194.2, 196.1, 198, 200, 201.9, 203.9, 205.8, 207.7, 209.7,
211.6, 213.6, 215.5, 217.4, 219.4, 221.3, 223.3, 225.2, 227.1,
229.1, 231, 232.9, 234.9, 236.8, 238.8, 240.7, 242.6, 244.6,
246.5, 248.5, 250.4, 252.3, 254.3, 256.2, 258.2, 260.1, 262,
264, 265.9, 267.8, 269.8, 271.7, 273.7, 275.6, 277.5, 279.5,
281.4, 283.4, 285.3, 287.2, 289.2, 291.1, 293, 295, 296.9, 298.9,
300.8), v = c(14.808, 14.808, 14.816, 14.816, 14.808, 14.804,
14.816, 14.8, 14.808, 14.808, 14.8, 14.804, 15.84, 15.844, 15.844,
15.844, 15.844, 15.848, 15.852, 15.848, 15.848, 15.852, 15.848,
15.852, 15.848, 15.852, 15.848, 15.852, 15.848, 15.848, 15.848,
15.852, 15.852, 15.852, 15.852, 15.852, 15.856, 15.856, 15.852,
15.852, 15.852, 15.852, 15.852, 15.852, 15.852, 15.856, 15.856,
15.856, 15.852, 15.852, 15.852, 15.848, 15.852, 15.856, 15.852,
15.852, 15.852, 15.856, 15.852, 15.852, 15.856, 15.856, 15.856,
15.856, 15.852, 15.856, 15.852, 15.852, 15.852, 15.856, 15.852,
15.856, 15.856, 15.856, 15.856, 15.856, 15.856, 15.856, 15.856,
15.856, 15.852, 15.848, 15.852, 15.852, 15.852, 15.856, 15.856,
15.856, 15.856, 15.856, 15.856, 15.856, 15.856, 15.86, 15.852,
15.852, 15.856, 15.852, 15.856, 15.852, 15.852, 15.856, 15.86,
15.856, 15.86, 15.856, 15.856, 15.856, 15.856, 15.852, 15.856,
15.852, 15.852, 15.856, 15.856, 15.856, 15.856, 15.856, 15.856,
15.856, 15.856, 15.856, 15.852, 15.852, 15.852, 15.852, 15.856,
15.856, 15.856, 15.856, 15.86, 15.856, 15.856, 15.86, 15.856,
15.856, 15.852, 15.856, 15.852, 15.856, 15.856, 15.856, 15.856,
15.856, 15.856, 15.856, 15.856, 15.852, 15.852, 15.852, 15.848,
15.852, 15.856, 15.856, 15.852), a = c(1.478, 1.472, 1.491, 1.49,
1.47, 1.484, 1.452, 1.473, 1.465, 1.482, 1.459, 1.481, 0.002,
0.002, 0.001, 0.002, 0.002, 0.002, 0.002, 0.001, 0.002, 0.002,
0.001, 0.001, 0.002, 0.002, 0.002, 0.002, 0.002, 0.002, 0.002,
0.001, 0.002, 0.001, 0.002, 0.001, 0.002, 0.001, 0.002, 0.001,
0.001, 0.001, 0.002, 0.002, 0.002, 0.002, 0.001, 0.002, 0.002,
0.001, 0.002, 0.002, 0.001, 0.002, 0.002, 0.002, 0.002, 0.001,
0.002, 0.002, 0.001, 0.002, 0.002, 0.001, 0.002, 0.002, 0.001,
0.002, 0.002, 0.002, 0.002, 0.002, 0.002, 0.002, 0.001, 0.002,
0.002, 0.002, 0.002, 0.002, 0.001, 0.002, 0.002, 0.002, 0.001,
0.002, 0.001, 0.002, 0.002, 0.002, 0.002, 0.002, 0.001, 0.002,
0.002, 0.002, 0.001, 0.002, 0.002, 0.002, 0.002, 0.002, 0.002,
0.002, 0.001, 0.001, 0.002, 0.002, 0.002, 0.002, 0.002, 0.002,
0.002, 0.002, 0.001, 0.002, 0.001, 0.002, 0.002, 0.002, 0.002,
0.002, 0.001, 0.002, 0.002, 0.002, 0.002, 0.002, 0.002, 0.002,
0.002, 0.001, 0.002, 0.002, 0.002, 0.001, 0.002, 0.002, 0.002,
0.002, 0.001, 0.002, 0.002, 0.002, 0.001, 0.001, 0.001, 0.001,
0.001, 0.002, 0.001, 0.002, 0.001, 0.001, 0.002), t1 = c(14.63,
14.63, 14.63, 14.63, 14.62, 14.62, 14.63, 14.63, 14.63, 14.64,
14.65, 14.67, 14.69, 14.71, 14.74, 14.76, 14.79, 14.83, 14.87,
14.9, 14.94, 14.98, 15.03, 15.06, 15.1, 15.14, 15.18, 15.21,
15.25, 15.28, 15.3, 15.33, 15.36, 15.38, 15.4, 15.42, 15.44,
15.46, 15.48, 15.49, 15.51, 15.52, 15.53, 15.54, 15.55, 15.56,
15.57, 15.58, 15.58, 15.59, 15.6, 15.6, 15.61, 15.61, 15.61,
15.62, 15.62, 15.62, 15.62, 15.63, 15.63, 15.63, 15.63, 15.63,
15.63, 15.64, 15.64, 15.64, 15.64, 15.64, 15.64, 15.64, 15.64,
15.64, 15.64, 15.64, 15.64, 15.63, 15.63, 15.63, 15.63, 15.63,
15.63, 15.63, 15.63, 15.63, 15.63, 15.63, 15.62, 15.62, 15.62,
15.62, 15.62, 15.62, 15.62, 15.62, 15.61, 15.61, 15.61, 15.61,
15.61, 15.61, 15.6, 15.6, 15.6, 15.6, 15.6, 15.6, 15.59, 15.59,
15.59, 15.59, 15.59, 15.59, 15.58, 15.58, 15.58, 15.58, 15.58,
15.58, 15.58, 15.57, 15.57, 15.57, 15.57, 15.57, 15.56, 15.56,
15.56, 15.56, 15.56, 15.56, 15.55, 15.55, 15.55, 15.55, 15.55,
15.54, 15.54, 15.54, 15.54, 15.54, 15.54, 15.53, 15.53, 15.53,
15.53, 15.53, 15.52, 15.52, 15.52, 15.52, 15.52, 15.52, 15.51
), t2 = c(14.64, 14.64, 14.64, 14.64, 14.64, 14.64, 14.64, 14.64,
14.65, 14.65, 14.67, 14.68, 14.7, 14.73, 14.76, 14.79, 14.83,
14.87, 14.92, 14.97, 15.02, 15.07, 15.13, 15.18, 15.23, 15.28,
15.33, 15.38, 15.42, 15.46, 15.5, 15.53, 15.56, 15.59, 15.62,
15.65, 15.67, 15.69, 15.71, 15.73, 15.75, 15.76, 15.78, 15.79,
15.8, 15.81, 15.82, 15.83, 15.84, 15.84, 15.85, 15.86, 15.86,
15.87, 15.87, 15.87, 15.88, 15.88, 15.88, 15.89, 15.89, 15.89,
15.89, 15.89, 15.89, 15.89, 15.89, 15.89, 15.89, 15.89, 15.89,
15.89, 15.89, 15.89, 15.89, 15.89, 15.89, 15.89, 15.89, 15.89,
15.89, 15.89, 15.88, 15.88, 15.88, 15.88, 15.88, 15.88, 15.88,
15.87, 15.87, 15.87, 15.87, 15.87, 15.86, 15.86, 15.86, 15.86,
15.86, 15.85, 15.85, 15.85, 15.85, 15.85, 15.84, 15.84, 15.84,
15.84, 15.83, 15.83, 15.83, 15.83, 15.82, 15.82, 15.82, 15.82,
15.81, 15.81, 15.81, 15.81, 15.8, 15.8, 15.8, 15.8, 15.79, 15.79,
15.79, 15.79, 15.78, 15.78, 15.78, 15.78, 15.77, 15.77, 15.77,
15.77, 15.76, 15.76, 15.76, 15.76, 15.75, 15.75, 15.75, 15.75,
15.74, 15.74, 15.74, 15.74, 15.73, 15.73, 15.73, 15.72, 15.72,
15.72, 15.72), t3 = c(14.65, 14.65, 14.65, 14.65, 14.65, 14.64,
14.65, 14.65, 14.65, 14.66, 14.68, 14.69, 14.72, 14.74, 14.77,
14.8, 14.84, 14.88, 14.92, 14.96, 15.01, 15.06, 15.1, 15.15,
15.19, 15.23, 15.27, 15.31, 15.35, 15.38, 15.41, 15.44, 15.47,
15.49, 15.52, 15.54, 15.56, 15.58, 15.59, 15.61, 15.62, 15.63,
15.64, 15.66, 15.66, 15.67, 15.68, 15.69, 15.69, 15.7, 15.71,
15.71, 15.71, 15.72, 15.72, 15.72, 15.73, 15.73, 15.73, 15.73,
15.73, 15.73, 15.73, 15.73, 15.73, 15.73, 15.73, 15.73, 15.73,
15.73, 15.73, 15.73, 15.73, 15.73, 15.73, 15.73, 15.73, 15.72,
15.72, 15.72, 15.72, 15.72, 15.72, 15.72, 15.71, 15.71, 15.71,
15.71, 15.71, 15.71, 15.7, 15.7, 15.7, 15.7, 15.7, 15.7, 15.69,
15.69, 15.69, 15.69, 15.69, 15.68, 15.68, 15.68, 15.68, 15.67,
15.67, 15.67, 15.67, 15.67, 15.67, 15.66, 15.66, 15.66, 15.66,
15.65, 15.65, 15.65, 15.65, 15.65, 15.64, 15.64, 15.64, 15.64,
15.64, 15.63, 15.63, 15.63, 15.63, 15.62, 15.62, 15.62, 15.62,
15.62, 15.61, 15.61, 15.61, 15.61, 15.61, 15.6, 15.6, 15.6, 15.6,
15.6, 15.59, 15.59, 15.59, 15.59, 15.58, 15.58, 15.58, 15.58,
15.58, 15.57, 15.57), t4 = c(14.66, 14.66, 14.66, 14.66, 14.66,
14.66, 14.66, 14.67, 14.67, 14.68, 14.7, 14.72, 14.74, 14.77,
14.8, 14.84, 14.88, 14.92, 14.97, 15.01, 15.06, 15.12, 15.17,
15.22, 15.26, 15.31, 15.36, 15.4, 15.44, 15.48, 15.51, 15.54,
15.57, 15.6, 15.63, 15.65, 15.67, 15.69, 15.71, 15.73, 15.74,
15.76, 15.77, 15.78, 15.79, 15.8, 15.81, 15.82, 15.83, 15.83,
15.84, 15.84, 15.85, 15.85, 15.86, 15.86, 15.86, 15.87, 15.87,
15.87, 15.87, 15.87, 15.87, 15.87, 15.88, 15.88, 15.88, 15.88,
15.88, 15.88, 15.88, 15.87, 15.87, 15.87, 15.87, 15.87, 15.87,
15.87, 15.87, 15.87, 15.87, 15.86, 15.86, 15.86, 15.86, 15.86,
15.86, 15.85, 15.85, 15.85, 15.85, 15.85, 15.84, 15.84, 15.84,
15.84, 15.84, 15.83, 15.83, 15.83, 15.83, 15.83, 15.82, 15.82,
15.82, 15.82, 15.82, 15.81, 15.81, 15.81, 15.81, 15.8, 15.8,
15.8, 15.8, 15.79, 15.79, 15.79, 15.79, 15.79, 15.78, 15.78,
15.78, 15.78, 15.77, 15.77, 15.77, 15.77, 15.76, 15.76, 15.76,
15.76, 15.75, 15.75, 15.75, 15.75, 15.75, 15.74, 15.74, 15.74,
15.74, 15.73, 15.73, 15.73, 15.73, 15.72, 15.72, 15.72, 15.71,
15.71, 15.71, 15.71, 15.71, 15.7, 15.7), t5 = c(14.67, 14.67,
14.67, 14.67, 14.67, 14.67, 14.67, 14.68, 14.69, 14.7, 14.72,
14.74, 14.77, 14.79, 14.83, 14.86, 14.9, 14.94, 14.98, 15.03,
15.08, 15.12, 15.17, 15.21, 15.25, 15.3, 15.33, 15.37, 15.41,
15.44, 15.47, 15.5, 15.53, 15.55, 15.58, 15.6, 15.62, 15.64,
15.66, 15.67, 15.69, 15.7, 15.71, 15.72, 15.73, 15.74, 15.75,
15.76, 15.77, 15.77, 15.78, 15.79, 15.79, 15.79, 15.8, 15.8,
15.8, 15.81, 15.81, 15.81, 15.81, 15.82, 15.82, 15.82, 15.82,
15.82, 15.82, 15.82, 15.82, 15.82, 15.82, 15.82, 15.82, 15.82,
15.82, 15.82, 15.81, 15.81, 15.81, 15.81, 15.81, 15.81, 15.81,
15.81, 15.8, 15.8, 15.8, 15.8, 15.8, 15.8, 15.79, 15.79, 15.79,
15.79, 15.79, 15.79, 15.78, 15.78, 15.78, 15.78, 15.78, 15.77,
15.77, 15.77, 15.77, 15.76, 15.76, 15.76, 15.76, 15.76, 15.75,
15.75, 15.75, 15.75, 15.75, 15.74, 15.74, 15.74, 15.74, 15.73,
15.73, 15.73, 15.73, 15.73, 15.72, 15.72, 15.72, 15.72, 15.71,
15.71, 15.71, 15.71, 15.71, 15.7, 15.7, 15.7, 15.7, 15.69, 15.69,
15.69, 15.69, 15.69, 15.68, 15.68, 15.68, 15.68, 15.67, 15.67,
15.67, 15.67, 15.67, 15.66, 15.66, 15.66, 15.66), t6 = c(14.65,
14.65, 14.65, 14.65, 14.65, 14.65, 14.65, 14.65, 14.66, 14.67,
14.69, 14.71, 14.73, 14.76, 14.79, 14.82, 14.85, 14.89, 14.93,
14.97, 15.01, 15.05, 15.09, 15.13, 15.17, 15.21, 15.24, 15.28,
15.31, 15.34, 15.37, 15.4, 15.42, 15.45, 15.47, 15.49, 15.51,
15.53, 15.55, 15.56, 15.58, 15.59, 15.61, 15.62, 15.63, 15.64,
15.65, 15.66, 15.67, 15.67, 15.68, 15.69, 15.69, 15.7, 15.7,
15.71, 15.71, 15.71, 15.72, 15.72, 15.72, 15.73, 15.73, 15.73,
15.73, 15.73, 15.74, 15.74, 15.74, 15.74, 15.74, 15.74, 15.74,
15.74, 15.74, 15.74, 15.74, 15.74, 15.74, 15.74, 15.74, 15.74,
15.74, 15.74, 15.74, 15.74, 15.74, 15.73, 15.73, 15.73, 15.73,
15.73, 15.73, 15.73, 15.73, 15.72, 15.72, 15.72, 15.72, 15.72,
15.72, 15.72, 15.71, 15.71, 15.71, 15.71, 15.71, 15.71, 15.71,
15.7, 15.7, 15.7, 15.7, 15.7, 15.69, 15.69, 15.69, 15.69, 15.69,
15.69, 15.68, 15.68, 15.68, 15.68, 15.68, 15.67, 15.67, 15.67,
15.67, 15.67, 15.66, 15.66, 15.66, 15.66, 15.66, 15.65, 15.65,
15.65, 15.65, 15.65, 15.64, 15.64, 15.64, 15.64, 15.64, 15.63,
15.63, 15.63, 15.63, 15.62, 15.62, 15.62, 15.62, 15.62, 15.61
), t7 = c(14.65, 14.65, 14.65, 14.65, 14.65, 14.65, 14.65, 14.66,
14.66, 14.67, 14.68, 14.7, 14.72, 14.74, 14.76, 14.79, 14.81,
14.84, 14.88, 14.91, 14.94, 14.98, 15.02, 15.05, 15.09, 15.12,
15.16, 15.19, 15.22, 15.25, 15.28, 15.3, 15.33, 15.35, 15.38,
15.4, 15.42, 15.44, 15.46, 15.47, 15.49, 15.5, 15.52, 15.53,
15.54, 15.55, 15.56, 15.57, 15.58, 15.59, 15.6, 15.61, 15.62,
15.62, 15.63, 15.64, 15.64, 15.65, 15.65, 15.66, 15.66, 15.67,
15.67, 15.67, 15.68, 15.68, 15.68, 15.68, 15.69, 15.69, 15.69,
15.69, 15.69, 15.7, 15.7, 15.7, 15.7, 15.7, 15.7, 15.7, 15.7,
15.7, 15.7, 15.71, 15.71, 15.71, 15.71, 15.71, 15.71, 15.71,
15.71, 15.71, 15.7, 15.7, 15.7, 15.7, 15.7, 15.7, 15.7, 15.7,
15.7, 15.7, 15.7, 15.7, 15.7, 15.7, 15.69, 15.69, 15.69, 15.69,
15.69, 15.69, 15.69, 15.69, 15.68, 15.68, 15.68, 15.68, 15.68,
15.68, 15.68, 15.67, 15.67, 15.67, 15.67, 15.67, 15.67, 15.67,
15.66, 15.66, 15.66, 15.66, 15.66, 15.66, 15.65, 15.65, 15.65,
15.65, 15.65, 15.65, 15.64, 15.64, 15.64, 15.64, 15.64, 15.63,
15.63, 15.63, 15.63, 15.63, 15.63, 15.62, 15.62, 15.62, 15.62
), t8 = c(14.62, 14.62, 14.62, 14.62, 14.62, 14.62, 14.62, 14.62,
14.63, 14.64, 14.66, 14.67, 14.7, 14.72, 14.75, 14.78, 14.82,
14.85, 14.89, 14.93, 14.97, 15.01, 15.05, 15.08, 15.12, 15.16,
15.19, 15.22, 15.25, 15.28, 15.3, 15.33, 15.35, 15.37, 15.39,
15.41, 15.42, 15.44, 15.45, 15.47, 15.48, 15.49, 15.5, 15.51,
15.52, 15.53, 15.54, 15.54, 15.55, 15.56, 15.56, 15.57, 15.57,
15.58, 15.58, 15.58, 15.59, 15.59, 15.59, 15.59, 15.6, 15.6,
15.6, 15.6, 15.6, 15.6, 15.61, 15.61, 15.61, 15.61, 15.61, 15.61,
15.61, 15.61, 15.61, 15.61, 15.61, 15.61, 15.61, 15.61, 15.61,
15.61, 15.61, 15.6, 15.6, 15.6, 15.6, 15.6, 15.6, 15.6, 15.6,
15.6, 15.6, 15.59, 15.59, 15.59, 15.59, 15.59, 15.59, 15.59,
15.59, 15.58, 15.58, 15.58, 15.58, 15.58, 15.58, 15.58, 15.58,
15.57, 15.57, 15.57, 15.57, 15.57, 15.57, 15.56, 15.56, 15.56,
15.56, 15.56, 15.56, 15.56, 15.55, 15.55, 15.55, 15.55, 15.55,
15.55, 15.54, 15.54, 15.54, 15.54, 15.54, 15.54, 15.53, 15.53,
15.53, 15.53, 15.53, 15.53, 15.52, 15.52, 15.52, 15.52, 15.52,
15.51, 15.51, 15.51, 15.51, 15.51, 15.51, 15.5, 15.5, 15.5, 15.5
))
CodePudding user response:
## subtract the column mean (based on first 5 rows) from all columns
demean <- function (DF) {
MEANS <- colMeans(DF[1:5, ])
data.frame(Map(`-`, DF, MEANS))
}
## apply `demean` over `totaldata`, which is a list of data frames
newdata <- lapply(totaldata, demean)