-2

i m trying to average raster daily datasets on monthly basis. For that i want to keep the name of output as varialbe. Can anyone help me out?

require(raster)
hab=list.files(getwd(), pattern="tif$", full.names=FALSE)

for (k in 1:length(hab)){

paste("January", k) <- stack(hab[1], .................., hab[30])

paste("Jan", k) <- mean(paste("January"), k)


.....

}
Christian Borck
  • 1,812
  • 1
  • 13
  • 19
  • 1
    Could you provide some exemplary code? On given data, what are the results you expect? – gagolews May 01 '14 at 16:22
  • Please [re-edit your question to provide us with more details](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example?rq=1). – gagolews May 01 '14 at 16:29

1 Answers1

0

Use assign and get to reference objects by a character string instead of symbols. Also, bear in mind that you won't be able to use names with spaces, so set sep='' when calling paste.

assign(paste("January", k, sep=''), stack(hab[1], .................., hab[30]))

assign(paste("Jan", k, sep=''), mean(get(paste("January", k, sep=''))))