Dear Group,

Need to do the following transformation:

I have the dataset
structure(list(Date = structure(1L, .Label = "2010-06-16", class =
"factor"), 
    ACC.returns1Day = -0.018524832, ACC.returns5Day = 0.000863931, 
    ACC.returns7Day = -0.019795222, BCC.returns1Day = -0.009861859, 
    BCC.returns5Day = 0.000850706, BCC.returns7Day = -0.014695715), .Names =
c("Date", 
"ACC.returns1Day", "ACC.returns5Day", "ACC.returns7Day", "BCC.returns1Day", 
"BCC.returns5Day", "BCC.returns7Day"), class = "data.frame", row.names =
c(NA, 
-1L))

I can split the names using:
retNames <- strsplit(names(returns),"\\.returns")

Assuming that the frame has only one row, how do I transform this into 

        1Day            5Day            7Day
ACC     -0.0185 0.0009  -0.0198
BCC     -0.0099 0.0009  -0.0147

If I have more than one unique date  ... is there some nice structure that I
could put this into where I have the date as the parent and the sub data
structure that gives the data as above for any unique date?

I can always do this with for-loops ... but I think there are easier ways to
achieve this.

Thanks,
S

______________________________________________
R-help@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.

Reply via email to