Displaying 4 results from an estimated 4 matches for "fun_bil".
Did you mean:
fun_bill
2017 Nov 29
0
dplyr - add/expand rows
...,i),
year =sequence(i) -1 + rep(from,i),
stringsAsFactors = FALSE)
}))
data.frame(station = rep(names(out), sapply(out,nrow)),
do.call(rbind,out),
row.names = NULL,
stringsAsFactors = FALSE)
}
## Bill - transform
fun_bill <- function(d) {
i <- rep(seq_len(nrow(d)), d$to-d$from+1)
j <- sequence(d$to-d$from+1)
transform(d[i,], year=from+j-1, from=NULL, to=NULL)
}
## Michael - IRanges
fun_michael <- function(d) {
df <- with(d, DataFrame(station, record, year=IRanges(from, to)))
expand(df...
2017 Nov 29
2
dplyr - add/expand rows
...from,i),
> ???????????????? stringsAsFactors = FALSE)
> ??? }))
> ? data.frame(station = rep(names(out), sapply(out,nrow)),
> ???????????? do.call(rbind,out),
> ???????????? row.names = NULL,
> ???????????? stringsAsFactors = FALSE)
> }
>
> ## Bill - transform
> fun_bill <- function(d) {
> ? i <- rep(seq_len(nrow(d)), d$to-d$from+1)
> ? j <- sequence(d$to-d$from+1)
> ? transform(d[i,], year=from+j-1, from=NULL, to=NULL)
> }
>
> ## Michael - IRanges
> fun_michael <- function(d) {
> ? df <- with(d, DataFrame(station, recor...
2017 Nov 29
0
dplyr - add/expand rows
...ingsAsFactors = FALSE)
>> }))
>> data.frame(station = rep(names(out), sapply(out,nrow)),
>> do.call(rbind,out),
>> row.names = NULL,
>> stringsAsFactors = FALSE)
>> }
>>
>> ## Bill - transform
>> fun_bill <- function(d) {
>> i <- rep(seq_len(nrow(d)), d$to-d$from+1)
>> j <- sequence(d$to-d$from+1)
>> transform(d[i,], year=from+j-1, from=NULL, to=NULL)
>> }
>>
>> ## Michael - IRanges
>> fun_michael <- function(d) {
>> df <- w...
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