Re: [R] Grouping by 3 variable and renaming groups

2018-05-26 Thread Jeff Reichman
Rui Your first code worked just fine. Jeff -Original Message- From: Rui Barradas Sent: Saturday, May 26, 2018 8:30 AM To: reichm...@sbcglobal.net; 'R-help' Subject: Re: [R] Grouping by 3 variable and renaming groups Hello, Sorry, but I think my first answer is wrong. Yo

Re: [R] Grouping by 3 variable and renaming groups

2018-05-26 Thread Jeff Reichman
Rui That did it Jeff -Original Message- From: Rui Barradas Sent: Saturday, May 26, 2018 8:23 AM To: reichm...@sbcglobal.net; 'R-help' Subject: Re: [R] Grouping by 3 variable and renaming groups Hello, See if this is it: priceStore_Grps$StoreID <- paste("St

Re: [R] Grouping by 3 variable and renaming groups

2018-05-26 Thread Rui Barradas
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.na

Re: [R] Grouping by 3 variable and renaming groups

2018-05-26 Thread Rui Barradas
Hello, See if this is it: priceStore_Grps$StoreID <- paste("Store", seq_len(nrow(priceStore_Grps)), sep = "_") Hope this helps, Rui Barradas On 5/26/2018 2:03 PM, Jeff Reichman wrote: ALCON I'm trying to figure out how to rename groups in a data frame after groups by selected variab