Quantcast

help in replacing for llop

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

help in replacing for llop

arunkumar1111
Hi

I have records like like this

X1 X2 State
34 72 state1
9 63 state1
49 31 state1
60 34 state1
80 73 state1
60 20 state2
59 87 state2
88 20 state2
71 66 state2
65 56 state2
59 16 state1
60 100 state2


I want to get the summarize value like mean median histogram for X1 and X2 based on state. I'm using FOR loop for this.  Is there any method to remove for loop and use apply or any alternatives
Thanks in Advance
        Arun
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: help in replacing for llop

Michael Weylandt
No idea what a "mean median histogram" is but you may wish to check
out ?tapply or library(plyr), both of which are designed for this
split-apply-combine paradigm.

Michael

On Tue, Mar 27, 2012 at 12:51 AM, arunkumar1111 <[hidden email]> wrote:

> Hi
>
> I have records like like this
>
> X1      X2      State
> 34      72      state1
> 9       63      state1
> 49      31      state1
> 60      34      state1
> 80      73      state1
> 60      20      state2
> 59      87      state2
> 88      20      state2
> 71      66      state2
> 65      56      state2
> 59      16      state1
> 60      100     state2
>
>
> I want to get the summarize value like mean median histogram for X1 and X2
> based on state. I'm using FOR loop for this.  Is there any method to remove
> for loop and use apply or any alternatives
>
>
> -----
> Thanks in Advance
>        Arun
> --
> View this message in context: http://r.789695.n4.nabble.com/help-in-replacing-for-llop-tp4507939p4507939.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Loading...