Skip to content

Break up a data frame

4 messages · Ravi S. Shankar, jim holtman, Henrique Dallazuanna +1 more

#
Is this close to what you want?
V1         V2    V3  V4
1 xyz 01/03/2007 15.25 USD
2 xyz 01/04/2007 15.32 USD
3 xyz 01/02/2008 23.22 USD
4 abc 01/03/2007 45.20 EUR
5 abc 01/04/2007 45.00 EUR
6 abc 01/02/2008 68.33 EUR
Using V1, V2, V4 as id variables
V1         V2    V3  V4
1 xyz 01/03/2007 15.25 USD
2 xyz 01/04/2007 15.32 USD
3 xyz 01/02/2008 23.22 USD
4 abc 01/03/2007 45.20 EUR
5 abc 01/04/2007 45.00 EUR
6 abc 01/02/2008 68.33 EUR
V2   EUR   USD
1 01/02/2008 68.33 23.22
2 01/03/2007 45.20 15.25
3 01/04/2007 45.00 15.32

        
On Thu, Mar 20, 2008 at 1:22 AM, Ravi S. Shankar <ravis at ambaresearch.com> wrote:

  
    
#
Or perhaps:

xtabs(V3 ~ V2 + V4, data=x)
On 20/03/2008, Ravi S. Shankar <ravis at ambaresearch.com> wrote:

  
    
#
"Ravi S. Shankar" <ravis at ambaresearch.com> wrote in
news:A36876D3F8A5734FA84A4338135E7CC3033BE60E at BAN-MAILSRV03.Amba.com:
Seeing what appeared to be wordwrap, I interpreted your request as asking 
for display of "xyz" rows adjacent to "abc" rows. If that is the case, 
then this seems to work for the toy example:
V1         V2    V3  V4
1 xyz 01/03/2007 15.25 USD
2 xyz 01/04/2007 15.32 USD
3 xyz 01/02/2008 23.22 USD
4 abc 01/03/2007 45.20 EUR
5 abc 01/04/2007 45.00 EUR
6 abc 01/02/2008 68.33 EUR
V1         V2    V3  V4  V1         V2    V3  V4
1 xyz 01/03/2007 15.25 USD abc 01/03/2007 45.20 EUR
2 xyz 01/04/2007 15.32 USD abc 01/04/2007 45.00 EUR
3 xyz 01/02/2008 23.22 USD abc 01/02/2008 68.33 EUR

If it was instead a request for USD next to EUR, then the needed 
modifications should be obvious.