I have a data frame consisting of 36 observations of 8 variables (the first two variables are factors and the last 6 are numeric). The structure looks like this:
Technology Sector 2011 2012 2013 2014 2015 mean
Photovoltaic Energy 10 20 30 10 30 20
Wind-based Energy 20 60 60 20 40 40
Cultivation Nature 10 10 20 30 30 20
I want to be get the mean for every technology, that has the string "based" in its name. I've done it that way:
df[[8]][c(grep("based",Technology))]
And it works exactly how it is supposed to. The task from my online course is, to do it also with one of the following: apply()-, lapply()-, sapply()- or tapply()-function. How can this be done?