N.Varela
N.Varela

Reputation: 910

R: How to use "stack" instead of "stack" (from raster package)?

I want to use the stack function in base R as shown in this answer of my earlier question. However, I am also using the raster package (which contains also a stack function) and this package retrieves always the error:

Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘raster’ for signature ‘"numeric"’

Is there a way to assign the package to the function? Or an idea how to use the stack function in base R and not of raster package?

Here the reproducible example of my earlier question:

library(raster)
group1 <- c(101, 106)
group2 <- c(102, 104)
group3 <- c(105, 103)
S <- stack(list(group1 = group1, group2 = group2, group3 = group3))

Thanks for your ideas.

Upvotes: 1

Views: 63

Answers (1)

RHertel
RHertel

Reputation: 23818

You could use the prefix utils:: like this

S <- utils::stack(list(group1 = group1, group2 = group2, group3 = group3))

Upvotes: 2

Related Questions