An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20081210/910ed2f9/attachment.pl>
how to merge panel data stored by variable?
5 messages · Stefan Grosse, Viktor Nagy, Hadley Wickham
I have two datasets stored in tab-separated format in the following way file1: country year1 year2 Germany var1 var1 Hungary var1 var1 file2: country year1 year2 Germany var2 var2 Hungary var2 var2 I can easily read in these files, but how can I merge them as a panel dataset?
?cbind ?rbind hth Stefan
2008/12/10 Stefan Grosse <singularitaet at gmx.net>
I have two datasets stored in tab-separated format in the following way file1: country year1 year2 Germany var1 var1 Hungary var1 var1 file2: country year1 year2 Germany var2 var2 Hungary var2 var2 I can easily read in these files, but how can I merge them as a panel dataset?
?cbind ?rbind
Thanks for your answer Stefan, but I think cbind/rbind does not solve my problem. After reading ?cbind I realised that first I should convert all the dataset to panel separately, and then I will be able to cbind/rbind it. So the question is how to read in the following data from a file as a panel dataset country year1 year2 Germany var1 var1 Hungary var1 var1 that is to have: country year var1 Germany year1 value1 Germany year2 value1 Hungary year1 value1 Hungary year2 value1 if I understand well, then I can run pdata.frame on the latter with id=country and time=year moreover, I'll be able to cbind several var1, var2, etc data files into one panel dataset Viktor
On Wed, Dec 10, 2008 at 1:54 PM, Viktor Nagy <viktor.nagy at gmail.com> wrote:
2008/12/10 Stefan Grosse <singularitaet at gmx.net>
I have two datasets stored in tab-separated format in the following way file1: country year1 year2 Germany var1 var1 Hungary var1 var1 file2: country year1 year2 Germany var2 var2 Hungary var2 var2 I can easily read in these files, but how can I merge them as a panel dataset?
?cbind ?rbind
Thanks for your answer Stefan, but I think cbind/rbind does not solve my problem. After reading ?cbind I realised that first I should convert all the dataset to panel separately, and then I will be able to cbind/rbind it. So the question is how to read in the following data from a file as a panel dataset country year1 year2 Germany var1 var1 Hungary var1 var1 that is to have: country year var1 Germany year1 value1 Germany year2 value1 Hungary year1 value1 Hungary year2 value1
Have a look at melt in the reshape package, http://had.co.nz/reshape. melt(mydf, id = "country") should do what you want. Hadley
wow, this package is amazing! Thank you! V 2008/12/10 hadley wickham <h.wickham at gmail.com>:
On Wed, Dec 10, 2008 at 1:54 PM, Viktor Nagy <viktor.nagy at gmail.com> wrote:
2008/12/10 Stefan Grosse <singularitaet at gmx.net>
I have two datasets stored in tab-separated format in the following way file1: country year1 year2 Germany var1 var1 Hungary var1 var1 file2: country year1 year2 Germany var2 var2 Hungary var2 var2 I can easily read in these files, but how can I merge them as a panel dataset?
?cbind ?rbind
Thanks for your answer Stefan, but I think cbind/rbind does not solve my problem. After reading ?cbind I realised that first I should convert all the dataset to panel separately, and then I will be able to cbind/rbind it. So the question is how to read in the following data from a file as a panel dataset country year1 year2 Germany var1 var1 Hungary var1 var1 that is to have: country year var1 Germany year1 value1 Germany year2 value1 Hungary year1 value1 Hungary year2 value1
Have a look at melt in the reshape package, http://had.co.nz/reshape. melt(mydf, id = "country") should do what you want. Hadley -- http://had.co.nz/
Viktor Nagy - http://viktornagy.com PhD student Toulouse School of Economics