getValues instead.
It returns the raster cell values for a RasterLayer or RasterBrick object that are currently in memory (typically after read* has been used).values(x, ...)x is a RasterLayer object. With the argument format='matrix' the function returns a matrix in stead of a vector; and in that case a further argument 'names=TRUE', will add row and column names getValues rather than values. values is typically used in functions after a read* function has been used and it will return all the values that happen to be in memory at that point, or fail if there are no values in memory. In contrast getValues will read values from disk if necessary.getValues