If with multiple variables you mean that your grouping variable has several different values, the split function will do the job for you:
## some data
Data = data.frame(value = c(rnorm(10000),rnorm(10000,5), rnorm(10000,10)), groups = rep(c('a','b','d'), each = 10000))
## the mean values for each group
DataMeans <- sapply(split(Data$value, Data$groups), mean)
## checking that the output corresponds with the simulated data (mean of a = 0, mean of b = 5)
DataMeans
## output
> DataMeans
a b d
0.00673895 4.99842741 9.98537344
But if you mean more variables (columns), and want the mean value for all combinations between the variables values, then you need tto create a list of the columns (on the argument called 'f'):
## some data
Data = data.frame(value = c(rnorm(10000),rnorm(10000,5), rnorm(10000,10)), groups = rep(c('a','b','d'), each = 10000), gender = rep(c('M','F'), each = 15000))
## the mean values for each group
DataMeans <- sapply(split(Data$value, f = list(Data$groups, Data$gender)), mean)
## checking that the output corresponds with the simulated data (mean of a = 0, mean of b = 5)
DataMeans
## output
> DataMeans
a.F b.F d.F a.M b.M d.M
NaN 4.995547802 10.007088587 0.003088001 4.982541806 NaN
AS you can see, it reports NaN for the combinations that does not exists on the data set, so, if you want only those that exists, then:
> DataMeans[is.finite(DataMeans)]
b.F d.F a.M b.M
4.995547802 10.007088587 0.003088001 4.982541806
cheers
Fer
Edit: the 'c' cames from 'concatenate'. That means exactly this. I am concatenating three random generated sets of 10000 values with a normal distribution but different means 0,5 and 10 (that is, adding one after another). It is used for creating vectors. So, if you want to create a vector with values 4,6,8,and 10, then you just type Vector <- c(4,6,8,10)