View source: R/data_management.R
group_prog_id | R Documentation |
Starting from a vector of group id, this function creates a progressive id inside each group. It uses C for efficiency
group_prog_id(group)
group |
a group vector |
set.seed(1)
## One factor id
x <- sample(c(rep("A",5), rep("C",3), rep("B",2), rep(NA,2)))
data.frame(group = x, id = group_prog_id(x) )
## Two factors id
y <- sample(gl(2,6, labels = c("C","D")))
data.frame(group1 = x, group2 = y, id = group_prog_id(interaction(x,y)) )
## example of sorting
db <- data.frame("group" = sample(gl(2,5)), "b" = Sys.Date() + 1:10)
db <- db[order( - as.integer(db$group), db$b),]
data.frame(db, id = group_prog_id(db$group))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.