Re: [R] Processing key_column, begin_date, end_date in R

2015-02-26 Thread jim holtman
here is yet another way: > dta <- read.csv( text= + "key_column,begin_date,end_date + 123456,2013-01-01,2014-01-01 + 123456,2013-07-01,2014-07-01 + 789102,2012-03-01,2014-03-01 + 789102,2015-02-01,2016-02-01 + 789102,2015-02-06,2016-02-06 + 789102,2015-02-28,2015-03-31 + 789102,2015-04-30,20

Re: [R] Processing key_column, begin_date, end_date in R

2015-02-26 Thread Jeff Newmiller
Here is another way. Have not tested for large scale efficiency, but if you convert dta to a data.table that might improve things. library(dplyr) dta <- read.csv( text= "key_column,begin_date,end_date 123456,2013-01-01,2014-01-01 123456,2013-07-01,2014-07-01 789102,2012-03-01,2014-03-01 789102,20

Re: [R] Processing key_column, begin_date, end_date in R

2015-02-26 Thread JS Huang
Hi, It's not as easy as I originally thought. Here is a revision with the function beginEnd to get it done. > date key_column begin_dateend_date 1 123456 2013-01-01 2014-01-01 2 123456 2013-07-01 2014-07-01 3 789102 2012-03-01 2014-03-01 4 789102 2015-02-01 2016-02-01

Re: [R] Processing key_column, begin_date, end_date in R

2015-02-26 Thread JS Huang
Hi, Here is an implemenation: > date key_column begin_dateend_date 1 123456 2013-01-01 2014-01-01 2 123456 2013-07-01 2014-07-01 3 789102 2012-03-01 2014-03-01 4 789102 2015-02-01 2016-02-01 5 789102 2015-02-06 2016-02-06 > y <- t(sapply(unique(date$key_column),

[R] Processing key_column, begin_date, end_date in R

2015-02-25 Thread Matt Gross
Hi, I am trying to process a large dataset in R. The dataset contains the following three columns: key_column - a unique key identifier begin_date - the start date of the active period end_date - the end date of the active period Example data is here: key_column,begin_date,end_date 123456,201