You would need a function like get() to do this.

I don't think you can "get" multiple objects in R.

You could do a loop:

layers <- get(names_raster[1])

for(i 2:length(names_raster)) layers <- stack(layers, get(names_raster[i]))

Jacob.


________________________________
 From: julio cesar oliveira <oliveirajc@ufv.br>
To: r-sig-geo@r-project.org 
Sent: Friday, 13 April 2012, 9:23
Subject: [R-sig-Geo] problem stack (RasterStack)

Dear list,

I have a file with names of raster (example: names_raster) and want create
a stack (multiple layers).

# example file
names_raster

[1] "img1" "img2" "img3" "img4" "img5"


#########################

# process ERROR

layers <- stack (noquote(paste(names_raster, collapse = ",", sep="")))


Erro em rep.int(names(x), lapply(x, length)) : valor de 'times' inválido

##########################


# Expected response

# noquote(paste(names_raster, collapse = ",", sep=""))

# img1,img2,img3,img4,img5


# process OK

#layers <- stack (img1,img2,img3,img4,img5)


Thanks

    [[alternative HTML version deleted]]


_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
	[[alternative HTML version deleted]]

