Re: [R] Dataframe: Average cells of two rows and replace them with one row

2014-05-30 Thread PIKAL Petr
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

Re: [R] Dataframe: Average cells of two rows and replace them with one row

2014-05-29 Thread PIKAL Petr
-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

Re: [R] Dataframe: Average cells of two rows and replace them with one row

2014-05-29 Thread Verena Weinbir
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

Re: [R] Dataframe: Average cells of two rows and replace them with one row

2014-05-28 Thread PIKAL Petr
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

Re: [R] Dataframe: Average cells of two rows and replace them with one row

2014-05-28 Thread Verena Weinbir
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

Re: [R] Dataframe: Average cells of two rows and replace them with one row

2014-05-27 Thread arun
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

Re: [R] Dataframe: Average cells of two rows and replace them with one row

2014-05-27 Thread Rui Barradas
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

Re: [R] Dataframe: Average cells of two rows and replace them with one row

2014-05-27 Thread Greg Snow
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

[R] Dataframe: Average cells of two rows and replace them with one row

2014-05-27 Thread Verena Weinbir
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