Hi
Please do not use html formating in your post. It does not bring any advantage.
See inline.
From: Verena Weinbir [mailto:vwein...@gmail.com]
Sent: Thursday, May 29, 2014 3:33 PM
To: PIKAL Petr
Subject: Re: [R] Dataframe: Average cells of two rows and replace them with one
row
Hey,
Thank you
-help
Subject: Re: [R] Dataframe: Average cells of two rows and replace them with one
row
Hello,
thank you for your reply.
Actually, the whole rows would have to be averaged anyways - my mistake :-)
Besides the first column "name" there is one other string (chr) variable "Test&q
nal Message-
> > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> > project.org] On Behalf Of Verena Weinbir
> > Sent: Wednesday, May 28, 2014 2:00 PM
> > To: arun
> > Cc: r-help
> > Subject: Re: [R] Dataframe: Average cells of two rows and repl
bject: Re: [R] Dataframe: Average cells of two rows and replace them
> with one row
>
> Hey guys,
>
> thank you very much for your help. Since I am a R-newbie I am still
> checking out how your code works and how I could adapt it to my
> dataframe,
> which has 124 rows and 41 colum
Hey guys,
thank you very much for your help. Since I am a R-newbie I am still
checking out how your code works and how I could adapt it to my dataframe,
which has 124 rows and 41 columns/variables. The first column would be
"name", the last ones, 40 and 41, contain the cells I want to average fo
Hi,
You can also try:
dat <- read.table(text="Name C1 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",sep="",header=TRUE,stringsAsFactors=FALSE)
library(plyr)
ddply(dat,.(Name),numcolwise(mean,na.rm=TRUE))
A.K.
On Tuesday, May 27, 2014 4:08 PM, Verena We
Hello,
Try the following.
dat <- read.table(text = "
Name C1 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
", header = TRUE)
str(dat)
aggregate(dat[, -1], list(dat$Name), mean)
Hope this helps,
Rui Barradas
Em 27-05-2014 21:06, Verena Weinbir escreve
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
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
9 matches
Mail list logo