[R] help in ddply
R. Michael Weylandt
michael.weylandt at gmail.com
Tue Apr 3 15:19:37 CEST 2012
Don't use ddply because you aren't returning a data.frame. Hist
objects are lists so use dlply.
dats <- structure(list(x = c(4L, 93L, 21L, 83L, 75L, 87L, 87L, 78L, 50L,
76L, 86L, 65L, 84L, 40L, 39L, 26L), panel = c(1L, 2L, 3L, 4L,
1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L)), .Names = c("x",
"panel"), class = "data.frame", row.names = c(NA, -16L))
#please start using dput -- I've asked this before
dlply(dats, "panel", function(d) hist(d$x))
It's up to you to interpret the results.
Michael
On Tue, Apr 3, 2012 at 4:02 AM, arunkumar1111 <akpbond007 at gmail.com> wrote:
> Hi
>
> I've records like this
> df=
> x panel
> 4 1
> 93 2
> 21 3
> 83 4
> 75 1
> 87 2
> 87 3
> 78 4
> 50 1
> 76 2
> 86 3
> 65 4
> 84 1
> 40 2
> 39 3
> 26 4
>
>
> i want to create histogram out of it . i want all the mid and count values
> for panel wise
>
> my code is
> histoutput = ddply(df,.(df[2]),hist)
>
> i'm not able to get the required result.
>
> please help me
> using for loop takes a lot of time if there are more records
>
> -----
> Thanks in Advance
> Arun
> --
> View this message in context: http://r.789695.n4.nabble.com/help-in-ddply-tp4528064p4528064.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.
More information about the R-help
mailing list