Dear R Users,
I'm trying to use the reshape package to 'melt' my gridded data into
column format. I've done this before on individual files, but this time
I'm trying to do it on a directory of files (with variable file names) -
therefore I have to also use the 'assign' command. I have come up
against a couple of problems however and am therefore seeking advice...
> assign(paste("Fekete_table_temp", index$year[i], index$month[i],
sep='')$Latitude,rownames(Fekete_198601)) # Using the row names of a
given file
Error in paste("Fekete_table_temp", index$year[i], index$month[i], sep
= "")$Latitude :
$ operator is invalid for atomic vectors
To get round this, I did:
assign(paste("Fekete_table_temp", index$year[i], index$month[i],
sep='')["Latitude"],rownames(Fekete_198601))
And for the actual loop in which the files are melted, I tried:
for (i in 1:120) {
Fekete_table_temp <- get(paste("Fekete_", index$year[i],
index$month[i], sep=''))
Fekete_table_long <- melt(Fekete_table_temp, id.var="Latitude",
na.rm=TRUE)
assign(paste("Fekete_long_", index$year[i], index$month[i],
sep=''), Fekete_table_long)
names(paste("Fekete_long_", index$year[i], index$month[i],
sep=''), c("Latitude", "Longitude",
paste("Obs",index$year[i], index$month[i], sep=''))
}
However, this results in:
Error: id variables not found in data: Latitude
...despite me having (supposedly) told it where 'Latitude' is, in
'Fekete_table_temp'.
What have I done wrong here?! And more importantly, how do I put it right?!
Many thanks for any help,
Steve
_________________________________________________________________
[[elided Hotmail spam]]