Is there a better way of reshaping dataframe data?
temp <- bdh(conn,c("AUDUSD Curncy","EURUSD Curncy"),"PX_LAST","20110101")
gives
head(temp)
ticker date PX_LAST
1 AUDUSD Curncy 2011-01-01 NA
2 AUDUSD Curncy 2011-01-02 NA
3 AUDUSD Curncy 2011-01-03 1.0205
4 AUDUSD Curncy 2011-01-04 1.0040
5 AUDUSD Curncy 2011-01-05 1.0014
6 AUDUSD Curncy 2011-01-06 0.9969
and
tail(temp)
ticker date PX_LAST
2127 EURUSD Curncy 2013-11-26 1.3557
2128 EURUSD Curncy 2013-11-27 1.3570
2129 EURUSD Curncy 2013-11-28 1.3596
2130 EURUSD Curncy 2013-11-29 1.3591
2131 EURUSD Curncy 2013-11-30 NA
2132 EURUSD Curncy 2013-12-01 NA
in other words, the data are just vertically tacked on to each other and further processing is necessary in order to get them working. how can i regroup this data into the various tickers, i.e.
head(temp)
AUDUSD.Curncy EURUSD.Curncy
2011-01-01 NA NA
2011-01-02 NA NA
2011-01-03 1.0205 1.3375
2011-01-04 1.0040 1.3315
2011-01-05 1.0014 1.3183
2011-01-06 0.9969 1.3028
All the reshaping questions I googled didnt have the kind of reshaping I wanted. I have implemented my own piecemeal solution given below but for learning's sake I wanted to ask you guys if there is a more elegant solution for this?