Dear R list, I'm having difficulties in choosing between a list or a data.frame, or an array for the storage and manipulation of my data (example follows). I've been using the three for different purposes but I would rather like to know which is more adapted to what task.
Here is the data I'm currently working on: 200 observations, each observation being a vector of length 1000 depending on several factors ("polarisation", "pitch", "dose", "size") > x <- seq(1,100,length = 1000) > observations <- matrix( rnorm(200*1000), ncol = 200) > > # factors > polarisation <- rep(c("0","90"), each = 100, length = 200) > pitch <- rep(1:5, length = 200) > dose <- rep(1:2, each =100, length = 200) > size <- rep(letters[1:6], each =100, length = 200) > > my.data <- list(x = x, > observations = as.data.frame(observations), > polarisation = factor(polarisation), > pitch = factor(pitch), > dose = factor(dose), > size = factor(size)) I would like to be able to manipulate the data in "observations" using the factors as opposed to column indices. For instance, I could plot all the observations corresponding to polarisation == "90" and pitch == "1", like in, > with(my.data , matplot(x, subset((pitch == "1") & (polarisation == > "90"), observations, type="l" ))) which doesn't work, so I've had to use, > with(my.data , matplot(x, observations[,(pitch == "1") & > (polarisation == "90")], type="l" )) Is this a sensible way to store and manipulate this sort of data? Is there anything more appropriate I've overlooked using data.frames only? Many thanks, baptiste _____________________________ Baptiste Auguié Physics Department University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag http://projects.ex.ac.uk/atto ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.