Say I'm looking at a large dataframe with some categorial string-variable and some unique name string-variable, and them some numerical variables (I have provided an example).
Now, I want to create a new dataframe, that has been reduced to the categorial variables, so that it contains only one row per category, in which I want to have the means of the numeric variables.
In my example, that would be a data frame with two rows which have the name variable "group1" and "group2" and furthermore contain means of it3
- it7
for each group. Thanks for any advice or ideas on where to look.
it1 <- c("group1", "group1", "group1", "group2", "group2", "group2","group2")
it2 <- c("Max", "Bob", "John", "Sarah", "Olivia", "Lucy", "Liam")
it3 <- c(0.6, 0.3, 0.1, 0.2, 0.3, 0.8, 0.8)
it4 <- c(0.5, 0.8, 0.1, 0.4, 0.4, 0.4, 0.5)
it5 <- c(0.4, 0.3, 0.1, 0.2, 0.5, 0.3, 0.9)
it6 <- c(0.5, 0.5, 0.3, 0.4, 0.2, 0.4, 0.2)
it7 <- c(0.2, 0.8, 0.6, 0.5, 0.4, 0.3, 0.8)
myframe <- cbind(it1, it2, it3, it4,it5, it6, it7)