Skip to content
Prev 374809 / 398506 Next

Grouping by 3 variable and renaming groups

Rui

Your first code worked just fine.

Jeff

-----Original Message-----
From: Rui Barradas <ruipbarradas at sapo.pt> 
Sent: Saturday, May 26, 2018 8:30 AM
To: reichmanj at sbcglobal.net; 'R-help' <r-help at r-project.org>
Subject: Re: [R] Grouping by 3 variable and renaming groups

Hello,

Sorry, but I think my first answer is wrong.
You probably want something along the lines of


sp <- split(priceStore_Grps, priceStore_Grps$StorePC) res <- lapply(seq_along(sp), function(i){
     sp[[i]]$StoreID <- paste("Store", i, sep = "_")
     sp[[i]]
})
res <- do.call(rbind, res)
row.names(res) <- NULL


Hope this helps,

Rui Barradas
On 5/26/2018 2:22 PM, Rui Barradas wrote: