[R] Simple one

jim holtman jholtman at gmail.com
Sat Jul 4 14:00:54 CEST 2009


mean(x[x[,'region'] == 'south', 'profit'])

or if dataframe

mean(x$profit[x$region == 'south'])

or for all regions

tapply(x$profit, x$region, mean)

On Fri, Jul 3, 2009 at 6:55 PM, JoK LoQ<jokloq at gmail.com> wrote:
>
> Just a quickly beginner's question.
>
> I wanna find the mean only from the values from a column related to specific
> values from another one. Like, theres a 'region' column, i want the mean of
> the value on 'profit' column only from "south" sells from 'region' column
> --
> View this message in context: http://www.nabble.com/Simple-one-tp24329691p24329691.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?




More information about the R-help mailing list