[R] Help with reshape/reshape2 needed

Thomas Adams
Wed, 05 Jul 2017 18:16:40 -0000

Hi all:

I'm struggling with getting my data re-formatted using functions in
reshape/reshape2 to get from:

1957 0.862500000
1958 0.750000000
1959 0.300000000
1960 0.287500000
1963 0.675000000
1964 0.937500000
1965 0.025000000
1966 0.387500000
1969 0.087500000
1970 0.275000000
1973 0.500000000
1974 0.362500000
1976 0.925000000
1978 0.712500000
1979 0.337500000
1980 0.700000000
1981 0.425000000
1982 0.212500000
1983 0.312500000
1986 0.237500000
1958 0.643564356
1963 0.250000000
1968 0.211538462
1976 0.317307692
1981 0.673076923
1985 0.730769231
1986 0.057692308
1957 0.073394495
1966 0.742574257
1961 0.082568807
1964 0.165137615
1965 0.137614679
1959 0.128712871
1968 0.587155963
1969 0.660550459
1970 0.477064220
1971 0.513761468
1973 0.449541284
1974 0.128440367
1968 0.415841584
1977 0.009174312
1979 0.339449541
1981 0.596330275
1982 0.348623853
1984 0.146788991
1986 0.651376147
1959 0.451923077
1965 0.750000000
1962 0.326732673
1964 0.782178218
1970 0.336538462
1975 0.277227723
1978 0.712871287
1957 0.509615385
1960 0.490384615
1961 0.721153846
1966 0.298076923
1969 0.413461538
1971 0.500000000
1972 0.692307692
1974 0.653846154
1984 0.049504950
1978 0.442307692
1973 0.079207921
1983 0.355769231
1984 0.038461538
1979 0.237623762
1982 0.564356436

to:

1957                  1958               1959             1960 ...
1985           1986
0.509615385  0.750000000  0.451923077  0.287500000 ...
0.651376147
0.509615385

and so on. It's likely the column lengths will be different, so I'm
guessing padding with NAs will be needed. I have on the order of 1335 rows
with years spanning 1957 to 2016.

Thank you...