-6

In R Studio I have a data set of 10 columns and I am required to add a further column (further variable) which is the average of 2 columns already there.

We have been told to use this formula: Tav = (Tmax+Tmin)/2 to create an extra column for the average of tmax and tmin but it does not work for me. I attach an image showing my situation:

I have tried to search for a solution on this site and others but cannot seem to find anything that helps my specific situation.

Thanks for any help in advance.

Roland
  • 127,288
  • 10
  • 191
  • 288
T.Barker
  • 1
  • 1
  • 1
    See `help("within")` and of course read [An Introduction to R](https://cran.r-project.org/doc/manuals/R-intro.pdf). – Roland Dec 21 '15 at 12:02

1 Answers1

2

Next time please read these first before posting: https://stackoverflow.com/help/how-to-ask How to make a great R reproducible example?

Based on your screenshot, I think this is what you're after:

 abp$tav <- (abp$tmax+abp$tmin)/2
Community
  • 1
  • 1
mtoto
  • 23,919
  • 4
  • 58
  • 71