After seeing Carsten's script it became clear that the problem was caused by
using a model that returns a "character type factor"  that has levels such
as "SAND". The raster::predict function uses as.integer(as.character(x)) to
convert factor levels and therefore all factors became NA. raster::predict
does that so that a '7' becomes a  7 (and not the index of the factor
levels). For now, use you should 'integer type factor' values with
raster::predict, but in the future raster::predict will accommodate both
cases. Robert


On Wed, Jul 27, 2011 at 11:42 AM, Carsten Neumann <carstennh@aol.com> wrote:

>  Dear all,
>
> after updating package raster_1.8-38 and randomForest_4.6-2 the predict()
> function fails to calculate a resulting rasterLayer. The Script always
> functioned well, before. Here is the problem:
>
> ##############################**#
> pred <- predict(b1, model1)
> class(b1) -> RasterStack
> class(model1) -> randomForest
>
> Warnmeldungen:
> 1: NAs durch Umwandlung erzeugt
> 2: NAs durch Umwandlung erzeugt
> ##############################**#
> The Error tells me that NA's are produced through conversion. But why???
> What do I have to change in comparison to former trials?
> (Input for randomForest: 1. factor variable   2. dataframe)
>
> I am thankfull for any help, because I want to present this function
> students on Friday.
>
> With best regards
>
> Carsten
>

	[[alternative HTML version deleted]]

