[R] Reading data with two rows of variable names using read.zoo

김상환 picnic101 at gmail.com
Tue Jul 28 18:41:50 CEST 2015


Dear R gurus.

I have a data file which has two rows of variable names.
And the time index has a little unusual format. I have no idea
how to handle two names and awkward indexing for the quarters.

Lines <- "
Index; UK; UK; JP; JP
Index; a1; a2; a1; a2
2009 2/4;2;4;3;2
2009 3/4;5;2;1;4
2009 4/4;7;1;1;6
2010 1/4;3;3;5;2
2010 2/4;5;1;2;1
"
(a snippet from a big data containing a1, a2, ..., a10 of many countries)

I want to sum a1 and a2 for UK, JP and obtain a zoo object like this:

            A    B
2009 Q2     6    5
2009 Q3     7    5
2009 Q4     8    7
2010 Q1     6    7
2010 Q2     6    3

This looks quite challenging. Thanks for your time.

	[[alternative HTML version deleted]]



More information about the R-help mailing list