Try something like this:
# get column numbers of 'wk' columns
col.num <- grep("^wk", names(yourDF))
# split out only the 'wk' columns
result <- lapply(split(yourDF[, col.num], paste(yourDF$x2,
paste(yourDF$x3))), function(.mrg){
colSums(.mrg)
})
On Thu, Nov 5, 2009 at 4:15 PM, Vadlamani, Sat
November 2009 10:16 a.m.
> To: 'R-help@r-project.org'
> Subject: [R] Merge records in the same dataframe
>
> Hi:
>
> Suppose that I have a data frame as below
>
> x1 x2 x3 ... x10 wk1 wk2 ... Wk208 (these are the column names)
>
> For each record, x1, x2
Hi:
Suppose that I have a data frame as below
x1 x2 x3 ... x10 wk1 wk2 ... Wk208 (these are the column names)
For each record, x1, x2, x3 ... x10 are attributes. and wk1, wk2, ..., wk208
are the sales recoreded for this attribute combination. Suppose that now, that
I want to do the following
3 matches
Mail list logo