Re: [R] recode Variable in dependence of values of two other variables

2011-08-12 Thread Dennis Murphy
Hi: Here are several equivalent ways to produce your desired output: # Base package: transform() df <- transform(df, mean = ave(x, id, FUN = mean)) # plyr package library('plyr') ddply(df, .(id), transform, mean = mean(x)) # data.table package library('data.table') dt <- data.table(df, key = '

Re: [R] recode Variable in dependence of values of two other variables

2011-08-12 Thread Mikhail Titov
org > Subject: [R] recode Variable in dependence of values of two other variables > > Hi, > > as an R-beginner, I have a recoding problem and hope you can help me: > > I am working on a SPSS dataset, which I loaded into R (load("C:/...) > > I have 2 existing Va

[R] recode Variable in dependence of values of two other variables

2011-08-12 Thread Julia Moeller
Hi, as an R-beginner, I have a recoding problem and hope you can help me: I am working on a SPSS dataset, which I loaded into R (load("C:/...) I have 2 existing Variables: "ID" and "X" , and one variable to be computed: meanX.dependID (=mean of X for all rows in which ID has the same value)