# file with one layer
fn <- system.file("external/test.grd", package="raster")
s <- stack(fn, fn)
r <- raster(fn)
s <- stack(r, fn)
nlayers(s)
# file with three layers
slogo <- stack(system.file("external/rlogo.grd", package="raster"))
nlayers(slogo)
slogo
Run the code above in your browser using DataLab