How can i extract the results plotted in the margin of the levelplot function?
Or is there a function that does the same thing?
I'm searching for something like a table...
Best regards,
library(raster)
library(rasterVis)
library(gridExtra)
f <- system.file("external/test.grd", package="raster")
r <- raster(f)
x <- levelplot(r, margin=T)
From the help page of rasterVis::levelplot
:
[These] marginal graphics show the column (x) and row (y) summaries of the
Raster*
object. The summary is computed with the functionmean
.
You should use the raster::zonal
function to compute them:
rx <- init(r, 'x')
mx <- zonal(r, rx, FUN = mean)
plot(mx, type = 'l')