Single row per id to multiple row per id
问题 I'd like to expand observations from single row-per-id to multiple rows-per-id based on a given time interval: > dput(df) structure(list(id = c(123, 456, 789), gender = c(0, 1, 1), yr.start = c(2005, 2010, 2000), yr.last = c(2007, 2012, 2000)), .Names = c("id", "gender", "yr.start", "yr.last"), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA, -3L)) > df # A tibble: 3 x 4 id gender yr.start yr.last <dbl> <dbl> <dbl> <dbl> 1 123 0 2005 2007 2 456 1 2010 2012 3 789 1 2000 2000 I want