[R-SIG-Finance] Question about re-order the dataframe

Brian Wu bwu at guzman.com
Tue Apr 10 20:32:51 CEST 2007


Hi, 
I have a data.frame as following,

     	   DATE TICKER    CLOSE
1  2000-06-30      A 73.75000
2  2000-07-07      A 67.43750
3  2000-07-14      A 76.87500
4  2000-07-21      A 47.50000
5  2000-07-28      A 41.31250
6  2000-06-30     BB 24.98000
7  2000-07-07     BB 23.60500
8  2000-07-14     BB 28.91750
9  2000-07-21     BB 27.73000
10 2000-07-28     BB 26.16750
11 2000-06-30   	CC 11.86500
12 2000-07-07   	CC 11.67750
13 2000-07-14   	CC 11.55250
14 2000-07-21   	CC 11.49000
15 2000-07-28   	CC 11.61500
16 2000-06-30    	DD 4.15625
17 2000-07-07     DD 4.62500
18 2000-07-14     DD  4.68750
19 2000-07-21    	DD 4.56250
20 2000-07-28     DD 4.18750

I wanna generate a matrix based on this data.frame has the TICKER as row nams and DATE as column names.
The matrix should be look like this:
	
	2000-06-30	2000-07-07	2000-07-14	2000-07-21	2000-07-28
A 	73.75000	 67.43750	 76.87500 	47.50000	 41.31250
BB	.....
CC	.....
DD	.....

Is there any easy way to do that?
One problem is there maybe TICKER doesn't have 5 CLOSEs.

Thanks for any suggestion!!!

Brian



More information about the R-SIG-Finance mailing list