Hello,
Maybe something like the following.
dat <- read.table(text = "
isin dt
1 FR0109970386 2010-01-12
2 FR0109970386 2011-01-12
3 FR0109970386 2012-01-12
4 FR0116114978 2010-01-12
5 FR0116114978 2011-01-12
6 FR0116114978 2012-01-12
", header = TRUE, stringsAsFactors = FALSE)
library(reshape2)
dcast(dat, dt ~ isin)[-1]
Hope this helps,
Rui Barradas
Em 17-06-2013 07:22, AlexPiche escreveu:> Hello Folks,
>
> I try to use plyr and reshape 2 to take a data frame of the form:
>
>> head(cf_dt)
> isin dt
> 1 FR0109970386 2010-01-12
> 2 FR0109970386 2011-01-12
> 3 FR0109970386 2012-01-12
> 4 FR0116114978 2010-01-12
> 5 FR0116114978 2011-01-12
> 6 FR0116114978 2012-01-12
>
> to create a matrix of the form
>
> FR0109970386 FR0116114978 ...
> 2010-01-12 2010-01-12 ...
> 2011-01-12 2011-01-12 ...
> 2012-01-12 2012-01-12 ...
> NA .... ...
> ... NA ...
> NA NA ....
>
> I would like to have 22 columns and 33 rows, since I have 22 bonds name and
> my longest cash flow is 33 dates long.
>
> Regards,
>
> Alex
>
>
>
>
>
> --
> View this message in context:
http://r.789695.n4.nabble.com/Data-frame-to-Matrix-by-category-tp4669669.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>