Dear R-helpers, I am trying to reshape a data frame that is in a wide format into a long format one. I have come across the reshape() function, but I have been very successful using it.
As an example: ll <- data.frame(time.1=seq(0.1,1,length=10),L1=rnorm(10),time.2=c(seq(1,7),rep(NA ,3)),R2=c(rnorm(7),rep(NA,3)),time.3=c(seq(1,1.5,length=3)+5,rep(NA,7)),M3=c (rnorm(3),rep(NA,7))) which gives me > ll time.1 L1 time.2 R2 time.3 M3 1 0.1 -0.41682731 1 -0.6734289 6.00 -1.7197765 2 0.2 0.45803536 2 -1.7629712 6.25 -0.1756395 3 0.3 0.70046943 3 1.0004967 6.50 -0.6492431 4 0.4 -0.44064572 4 -1.9410689 NA NA 5 0.5 -0.16925252 5 1.3035123 NA NA 6 0.6 -0.06501635 6 1.5709351 NA NA 7 0.7 0.50151676 7 0.1625204 NA NA 8 0.8 -0.78538134 NA NA NA NA 9 0.9 -0.08774319 NA NA NA NA 10 1.0 1.23420424 NA NA NA NA > I have some NA data given that different subjects have different number of measures and the rate of measurements is different between subjects. I would like to have a data frame with three variables: 1) time 2) Measure 3) Subject of the form time Measure Subject 0.1 -0.41682731 L1 ... ... ... 6.50 -0.6492431 M3 I have tried with reshape and the closest I've got to it was, reshape(ll,idvar="Time",varying=list(names(ll)),v.names="Strain",timevar="ID ",direction="long") Could anybody give me some help? thanks in advance, Jesus -------------------------------------------------------------- Jesús María Frías Celayeta School of Food Sci. and Env. Health. Faculty of Tourism and Food Dublin Institute of Technology Cathal Brugha St., Dublin 1. Ireland t +353 1 4024459 f +353 1 4024495 w www.dit.ie/DIT/tourismfood/science/staff/frias.html -------------------------------------------------------------- -- This message has been scanned for content and viruses by the DIT Information Services MailScanner Service, and is believed to be clean. http://www.dit.ie ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html