[R] Dataframe: Average cells of two rows and replace them with one row
Greg Snow
538280 at gmail.com
Tue May 27 22:13:50 CEST 2014
Look at the aggregate function. As long as you have a column like
Name that indicates which rows should be averaged together it will
work (technically it will average the other rows as well, but since
the average of 1 number is that number you will not see a difference).
On Tue, May 27, 2014 at 2:06 PM, Verena Weinbir <vweinbir at gmail.com> wrote:
> Hello,
>
> I have a big dataframe, and want to average two specific cells of two
> specific rows and then replace those two rows with one row which contains
> the averaged cells. Example (row 3 and 4: Cells2 and Cells3 averaged and
> replaced)
>
> NameC1 C2 C3
> 1 A 3 3 5
> 2 B 2 7 4
> 3 C 4 3 3
> 4 C 4 4 6
> 5 D 5 5 3
>
>
>
> NameC1 C2 C3
> 1 A 3 3 5
> 2 B 2 7 4
> 3 C 4 3.5 4.5 4 D 5 5 3
>
>
> Many thanks in advance!
>
> Best,
>
> Verena
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
--
Gregory (Greg) L. Snow Ph.D.
538280 at gmail.com
More information about the R-help
mailing list