On 06/28/02 17:57, Patrick Hausmann wrote:>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.
t() likes to have a matrix, not a data frame. So you can say
something like
as.data.frame(t(as.matrix(data.frame(MY.DATA.FRAME))))
--
Jonathan Baron, Professor of Psychology, University of Pennsylvania
R page: http://finzi.psych.upenn.edu/
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._