Hi there, I have a data.frame (pwt6) which I would like to transform: country year gdp MEX 1950 2 MEX 1951 5 BOL 1950 4 BOL 1951 12 ITA 1950 45 ITA 1951 2 This should be the result: year MEX.gdp BOL.gdp ITA.gdp 1950 2 4 45 1951 5 12 2 Right now I have this code (better - no code): country.label<-names(table(pwt6$country)) result<-data.frame(year=NULL) for(i in country.label) ? Thanks for any help, Patrick ------------- Patrick Hausmann Friedrich-Wilhelm Str. 37 - D-28199 Bremen Tel. +49 421 5980631 - Fax. +49 421 5980632 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
"Patrick Hausmann" <patrick.hausmann at uni-bremen.de> writes:> Hi there, > > I have a data.frame (pwt6) which I would like to transform: > > country year gdp > MEX 1950 2 > MEX 1951 5 > BOL 1950 4 > BOL 1951 12 > ITA 1950 45 > ITA 1951 2 > > This should be the result: > year MEX.gdp BOL.gdp ITA.gdp > 1950 2 4 45 > 1951 5 12 2 > > Right now I have this code (better - no code): > country.label<-names(table(pwt6$country)) > result<-data.frame(year=NULL) > for(i in country.label) > ?This is what reshape() is for. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._