[Solved] R: create seat number using seat from, seat to, n.tickets [duplicate]


Using base R you can do something like this

do.call("rbind", lapply(split(dd, 1:nrow(dd)), function(x) {
  data.frame(dd[1:3], seat=dd[1,4]:dd[1,5], dd[6:7])
}))

tested with

dd <- read.csv(text="event , section , row, seat from , seat to, price, n.tickets
1,       A,      10,    6,         8,      120,    3")

Here we split up the data.frame by rows, then create a new data.frame by expanding out the seat numbers, then we merge all the data.frames back together with do.call("rbind",...")

1

solved R: create seat number using seat from, seat to, n.tickets [duplicate]