0

I have a painfully simple question. Due to small sample sizes I want to group several species for analysis. I am trying to make a new variable which has calculated the means of columns 13, 15, 16 and 17.

David Arenburg
  • 91,361
  • 17
  • 137
  • 196
R Beginner
  • 109
  • 1
  • 4
  • 12
  • 3
    Welcome to StackOverflow! Please read the info about [how to ask a good question](http://stackoverflow.com/help/how-to-ask) and how to give a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610). This will make it much easier for others to help you. – Jaap Dec 06 '15 at 16:09

1 Answers1

0

to compute the mean of a column, just call the colMeans function, eg to get the mean of the first column in the following dataframe example:

df <- data.frame(rnorm(4),rnorm(4),rnorm(4))
meanFirstCol <- colMeans(df[1])
tagoma
  • 3,896
  • 4
  • 38
  • 57