How can I convert the following a data frame (panel data) to zoo? let df indicates my data frame;
Ctry year Carx Brx
A 2000 23 12
A 2001 18 16
A 2002 20 20
A 2003 NA 18
A 2004 24 NA
A 2005 18 12
B 2000 NA 22
B 2001 NA 20
B 2002 NA 14
B 2003 NA NA
B 2004 18 NA
B 2005 16 14
C 2000 NA NA
C 2001 NA 25
C 2002 24 32
C 2003 21 NA
C 2004 NA 15
C 2005 24 NA
I have tried the following code
df.zoo=zoo(df[,-2], order.by=as.Date(strptime(as.character(df[,2]), "%Y")))
I obtain the following result with a warning: "some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique"
year Ctry Carx Brx
2000-06-02 A 23 12
2000-06-02 B NA 22
2000-06-02 C NA NA
.. .. .. ..
What is the most suitable form of conversion for the above data frame to perform functions in zoo package?
many thanks for your help...