On 11/29/2017 05:47 PM, Tóth Dénes wrote:
Hi Martin,
On 11/29/2017 10:46 PM, Martin Morgan wrote:
On 11/29/2017 04:15 PM, Tóth Dénes wrote:
Hi,
A benchmarking study with an additional (data.table-based) solution.
I don't think speed is the right benchmark (I do agree that
correctness is!)
Hi Martin,
On 11/29/2017 10:46 PM, Martin Morgan wrote:
On 11/29/2017 04:15 PM, Tóth Dénes wrote:
Hi,
A benchmarking study with an additional (data.table-based) solution.
I don't think speed is the right benchmark (I do agree that correctness
is!).
Well, agree, and sorry for the wording.
On 11/29/2017 04:15 PM, Tóth Dénes wrote:
Hi,
A benchmarking study with an additional (data.table-based) solution.
I don't think speed is the right benchmark (I do agree that correctness
is!).
For the R-help list, maybe something about least specialized R knowledge
required would be appro
Hi,
A benchmarking study with an additional (data.table-based) solution.
Enjoy! ;)
Cheers,
Denes
--
## packages ##
library(dplyr)
library(data.table)
library(IRanges)
library(microbenchmark)
## prepare example dataset ###
## use Be
Bill et al.:
Yes, I see it now. Thank you for the correction.
-- Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Tue, Nov 28, 2017 at 1:42 PM, William D
Bert wrote
... Bill's solution seems to be for only one station.
No, it works for any number of stations.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Sun, Nov 26, 2017 at 11:10 AM, Bert Gunter
wrote:
> To David W.'s point about lack of a suitable reprex ("reproducible
> example"), Bill's
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
1 07EA001 1960 QMS
2 07EA001 1961 QMC
3 0
On 11/26/2017 08:42 PM, jim holtman wrote:
try this:
##
library(dplyr)
input <- tribble(
~station, ~from, ~to, ~record,
"07EA001" ,1960 , 1960 , "QMS",
"07EA001" , 1961 , 1970 , "QMC",
"07EA001" ,1971 , 1971 , "QMM",
"07EA0
try this:
##
library(dplyr)
input <- tribble(
~station, ~from, ~to, ~record,
"07EA001" ,1960 , 1960 , "QMS",
"07EA001" , 1961 , 1970 , "QMC",
"07EA001" ,1971 , 1971 , "QMM",
"07EA001" ,1972 , 1976 , "QMC",
"07EA001" ,1
To David W.'s point about lack of a suitable reprex ("reproducible
example"), Bill's solution seems to be for only one station.
Here is a reprex and modification that I think does what was requested for
multiple stations, again using base R and data frames, not dplyr and
tibbles.
First the reprex
> On Nov 25, 2017, at 11:18 AM, Hutchinson, David (EC)
> wrote:
>
> I have a returned tibble of station operational record similar to the
> following:
>
>> data.collection
> # A tibble: 5 x 4
> STATION_NUMBER YEAR_FROM YEAR_TO RECORD
>
> 107EA001 1960196
dplyr may have something for this, but in base R I think the following does
what you want. I've shortened the name of your data set to 'd'.
i <- rep(seq_len(nrow(d)), d$YEAR_TO-d$YEAR_FROM+1)
j <- sequence(d$YEAR_TO-d$YEAR_FROM+1)
transform(d[i,], YEAR=YEAR_FROM+j-1, YEAR_FROM=NULL, YEAR_TO=NULL)
I have a returned tibble of station operational record similar to the following:
> data.collection
# A tibble: 5 x 4
STATION_NUMBER YEAR_FROM YEAR_TO RECORD
107EA001 19601960QMS
207EA001 19611970QMC
307EA001 1971197
13 matches
Mail list logo