[R] Transpose a dataframe

Patrick Hausmann patrick.hausmann at uni-bremen.de
Fri Jun 28 17:57:17 CEST 2002


Hello,

I would like to switch this dataframe:
> k
    country  1960  1961  1962  1963
99      ARG  7493  7733  7581  7108
246     AUS 10484 10342 10809 11357
295     AUT  7438  7808  7938  8212
393     BDI   587   502   555   608
442     BEL  8223  8638  9021  9311

in this structure:

year	ARG	AUS	AUT	BDI	BEL
1960	7493	10484	7438	587	8223
1961	7733	10342	7808	502	8638
1962	7581	10809	7938	555	9021
1963	7108	11357	8212	608	9311

I'm trying the 'reshape' and 't' command, but still failed.

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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list