Skip to content
Prev 26999 / 29559 Next

raster::predict example doesn't work?

Dear Genoveva,

All the examples in the help file of package 'party' 
(https://cran.r-project.org/web/packages/party/party.pdf) use the 
function predict() from package 'stats' instead of package 'raster'.
But converting the RasterStack to data.frame, changing the column 'red' 
from numeric to factor, using stats::predict(..., newdata), and create a 
new layer of the RasterStack can solve the problem.
logo_df <- as.data.frame(logo)
logo_df$red <- factor(logo_df$red, levels = levels(v$red))
pc <- stats::predict(m, OOB = TRUE, newdata = logo_df)
logo$pc <- pc

HTH,
?kos Bede-Fazekas
Hungarian Academy of Sciences


2018.12.04. 15:52 keltez?ssel, Gonzalez-Mirelis, Genoveva ?rta: