[R] by group
Bert Gunter
bgunter@4567 @end|ng |rom gm@||@com
Tue Nov 2 02:34:45 CET 2021
... maybe not. According to Rdocumentation.org:
reshape2's status is:
reshape2 is retired: only changes necessary to keep it on CRAN will be
made. We recommend using tidyr <http://tidyr.tidyverse.org/> instead.
Bert Gunter
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Mon, Nov 1, 2021 at 5:55 PM Rasmus Liland <jral using posteo.no> wrote:
> Dear Val,
>
> also consider using reshape2::dcast
>
> dat <- structure(list(Year = c(2001L,
> 2001L, 2001L, 2001L, 2001L, 2001L,
> 2002L, 2002L, 2002L, 2002L, 2002L,
> 2002L, 2003L, 2003L, 2003L, 2003L,
> 2003L, 2003L), Sex = c("M", "M", "M",
> "F", "F", "F", "M", "M", "M", "F", "F",
> "F", "M", "M", "M", "F", "F", "F"), wt =
> c(15L, 14L, 16L, 12L, 11L, 13L, 14L,
> 18L, 17L, 11L, 15L, 14L, 18L, 13L, 14L,
> 15L, 10L, 11L)), class = "data.frame",
> row.names = c(NA, -18L))
>
> reshape2::dcast(data=dat,
> formula=Year~Sex,
> value.var="wt",
> fun.aggregate=mean)
>
> yielding
>
> Year F M
> 1 2001 12.00000 15.00000
> 2 2002 13.33333 16.33333
> 3 2003 12.00000 15.00000
>
> Best,
> Rasmus
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list