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 = '
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
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)
3 matches
Mail list logo