Bernardo Rangel Tura <tura <at> centroin.com.br> writes:

: original data base:
: 
: Age     x1980   x1981
: 1       5       8
: 3       7       9
: 5       9       15
: 7       11      20
: 
: future data base
: 
: year    age     x
: 1980    1       5
: 1980    3       7
: 1980    5       9
: 1980    7       11
: 1981    1       8
: 1981    3       9
: 1981    5       15
: 1981    7       20

Use reshape like this:

yn <- names(D)[2:3]
reshape(D, dir = "long", varying = list(yn), times = yn, v.names = "x")

and then do whatever fix ups you need on the result.

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to