I want to find an average of every 3 columns in data frame which contains 60 columns so that a new data frame would have 20 columns or so. I am putting sample data as below: Also, the new variable, if I can pass them as an array of string, would help.
structure(list(`1961` = c(0, 0, 0, 0, 0, 0, 0, 0, 4.633, 54.247,
0, 0, 0, 0, 0, 0, 0, 31.036, 3.18, 19.862), `1962` = c(0, 0,
0, 0, 0, 0, 0, 0, 4.168, 63.587, 0, 0, 0, 0, 0, 0, 0, 28.169,
2.913, 17.273), `1963` = c(0, 0, 0, 0, 0, 0, 0, 0, 3.284, 56.888,
0, 0, 0, 0, 0, 0, 0, 26.667, 2.653, 16.586), `1964` = c(0, 0,
0, 0, 0, 0, 0, 0, 2.689, 48.722, 0, 0, 0, 0, 0, 0, 0, 25.483,
3.873, 15.708), `1965` = c(0, 0, 0, 0, 0, 0, 0, 0, 3.304, 33.838,
0, 0, 0, 0, 0, 0, 0, 28.164, 3.927, 11.147), `1966` = c(0, 0,
0, 0, 0, 0, 0, 0, 2.871, 26.695, 0, 0, 0, 0, 0, 0, 0, 28.962,
4.434, 14.056), `1967` = c(0, 0, 0, 0, 0, 0, 0, 0, 2.752, 36.246,
0, 0, 0, 0, 0, 0, 0, 30.877, 4.739, 14.765), `1968` = c(0, 0,
0, 0, 0, 0, 0, 0, 3.537, 33.368, 0, 0, 0, 0, 0, 0, 0, 25.628,
5.445, 14.372), `1969` = c(0, 0, 0, 0, 0, 0, 0, 0, 2.484, 35.711,
0, 0, 0, 0, 0, 0, 0, 27.123, 5.286, 15.527)), row.names = c("Almonds, with shell",
"Anise, badian, fennel, coriander", "Apples", "Apricots", "Areca nuts",
"Asparagus", "Avocados", "Bananas", "Barley", "Bastfibres, other",
"Beans, dry", "Beans, green", "Berries nes", "Broad beans, horse beans, dry",
"Buckwheat", "Cabbages and other brassicas", "Carrots and turnips",
"Cashew nuts, with shell", "Cassava", "Castor oil seed"), class = "data.frame")