[R] Exclude 2014 data from mean

Sarah Goslee sarah.goslee at gmail.com
Fri Jul 31 22:38:09 CEST 2015


Hi Adam,

Possibly subset() or & would be helpful. Or even aggregate(),
depending on your ultimate goal.

Without a reproducible example that includes some sample data provided
using dput() (fake is fine), the code you used, and some clear idea of
what output you expect, it's impossible to figure out how to help you.
Here are some suggestions for creating a good reproducible example:
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

Sarah


On Fri, Jul 31, 2015 at 2:49 PM, Adam Jauregui <adma89 at gmail.com> wrote:
> Hello R-help,
>
> I am trying to compute the mean of a quarterback's career fantasy football
> stats, but I wish to exclude his 2014 stats from the mean, as that will be
> the test data for the model I am trying to build for my academic undergrad
> research.
>
> The code for figuring out the mean of his Yds for every career Game 1 was
> simple:
>
>
> *mean(brady.t$Yds[brady.t$G. == 1])*
> How can I make an "if-then" statement though so that his 2014 stats are
> excluded? Or is there an easier way besides "if-then?"
>
> Thank you,
>
> AKJ
>
>         [[alternative HTML version deleted]]
>

-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list