search for: d_dt

Displaying 4 results from an estimated 4 matches for "d_dt".

Did you mean: d_df
2017 Nov 29
0
dplyr - add/expand rows
...) stations <- rle(d_df$station) stations$value <- gsub( " ", "0", paste0("station", format(1:length(stations$value), width = 6))) d_df$station <- rep(stations$value, stations$lengths) ## prepare tibble and data.table versions d_tbl <- as_tibble(d_df) d_dt <- as.data.table(d_df) ## solutions ########################## ## Bert - by fun_bert <- function(d) { out <- by( d, d$station, function(x) with(x, { i <- to - from +1 data.frame(record =rep(record,i), year =sequence(i) -1 + rep(from,i),...
2017 Nov 29
2
dplyr - add/expand rows
...stations$value <- gsub( > ? " ", "0", > ? paste0("station", format(1:length(stations$value), width = 6))) > d_df$station <- rep(stations$value, stations$lengths) > > ## prepare tibble and data.table versions > d_tbl <- as_tibble(d_df) > d_dt <- as.data.table(d_df) > > ## solutions ########################## > > ## Bert - by > fun_bert <- function(d) { > ? out <- by( > ??? d, d$station, function(x) with(x, { > ????? i <- to - from +1 > ????? data.frame(record =rep(record,i), > ???????????...
2017 Nov 29
0
dplyr - add/expand rows
...>> " ", "0", >> paste0("station", format(1:length(stations$value), width = 6))) >> d_df$station <- rep(stations$value, stations$lengths) >> >> ## prepare tibble and data.table versions >> d_tbl <- as_tibble(d_df) >> d_dt <- as.data.table(d_df) >> >> ## solutions ########################## >> >> ## Bert - by >> fun_bert <- function(d) { >> out <- by( >> d, d$station, function(x) with(x, { >> i <- to - from +1 >> data.frame(record...
2017 Nov 28
2
dplyr - add/expand rows
Or with the Bioconductor IRanges package: df <- with(input, DataFrame(station, year=IRanges(from, to), record)) expand(df, "year") DataFrame with 24 rows and 3 columns station year record <character> <integer> <character> 1 07EA001 1960 QMS 2 07EA001 1961 QMC 3 07EA001 1962 QMC 4