Skip to content
Prev 175979 / 398503 Next

Help pasting string as object name

Hi,

Is this what you want?

d <- data.frame(density.AL = seq(1, 10),
	density.AK = seq(1, 10),  # many others...
	Date=letters[1:10]) # dummy example
	
library(reshape)
melt(subset(d, Date == "b"), id="Date")


BTW, I spotted a few awkward things in your code,


st <- c("AL", "AK")
vars <- paste("d$density", st, sep=".") # easier than mapply etc.

more importantly, in the for loop you should not be incrementing i  
manually (as in a while loop), it's already taken care of by the for{}  
construct.



HTH,

baptiste
On 3 Apr 2009, at 10:40, Rob Denniker wrote:

            
_____________________________

Baptiste Augui?

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag