[Biomod-commits] error trying to read myBiomodModelOut
Damien Georges
damien.georges2 at gmail.com
Tue May 14 13:09:35 CEST 2013
Dear Josep,
This is due to an add on biomod_modelling objects between the version
you used to build your models and the one curently installed on your
computer..
If models building is quite time consuming, you could try to use the
function attached to try to convert you Modeling outputs objects. If it
fails, maybe you will have to re-run it all.
Here the code of the function :
##########################################
update_biomod2_object <- function(obj){
## This function was created to convert if possible biomod2 objects
build with an old version of the package to the current one
## It can be particulary usefull in case of package updating.
## Damien G. - 13/05/14
## some constant definitions
supported_class <-
c("BIOMOD.formated.data","BIOMOD.formated.data.PA",
"BIOMOD.Model.Options", "BIOMOD.models.out", "BIOMOD.projection.out" )
## class checking
obj_class <- class(obj)
if( ! ( obj_class %in% supported_class ) ) stop("object to update
must inherit from one of : ", toString(supported_class), "class")
## create a reference object
ref_obj <- new(obj_class) #new(obj_class,obj)
## detect the slot to update
ref_slot <- slotNames(ref_obj)
to_update_slot <- sapply(ref_slot,function(X){
test <- try(slot(obj,X),silent=T)
if(inherits(test, "try-error")){
return(X)
} else{ return(NA) }
})
to_update_slot <- na.exclude(unlist(to_update_slot))
## update object
if(length(to_update_slot)){
for(t_u_s in to_update_slot){
# set a null modeling id
if(t_u_s == "modeling.id"){
obj at modeling.id = ""
} else{
slot(obj, t_u_s) <- slot(ref_obj, t_u_s)
}
}
cat("\n object updated!")
} else { cat("\n noting to do!") }
return(obj)
}
## Example
# myBiomodModelling <- update_biomod2_object(myBiomodModelling)
##########################################
Tell me if that helps,
Best,
Damien.
On 14/05/2013 10:59, Josep M Serra diaz wrote:
> Dear list,
>
> I performed some modeling two months ago. I saved the session in a
> .RData file.
>
> Now I want to project them to future conditions so I loaded the
> sessions, specified correctly the working directory, but when trying
> to project an error arises. It seems that it is attempting at finding
> a slot name modeling id, which is not stored or something.
>
> I checked all other results of modeling and they seemed ok
> (e.g.myBiomodData)
>
>
> Any hint?
>
> Pep
> ##########################################################
>
> BiomodProj.Present <- BIOMOD_Projection (modeling.output =
> myBiomodModelOut,
> + new.env = expl.var ,
> + proj.name <http://proj.name> = paste('CRU_strategy_',strategy,sep=''),
> + selected.models = 'all',
> + binary.meth = 'TSS',
> + compress = 'xz',
> + clamping.mask = T
> + ) #end BIOMOD_PROJECTION
>
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Do
> Models Projections
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> -=-=-=-=
> Error en cat("\nModeling id :", object at modeling.id
> <mailto:object at modeling.id>, fill = .Options$width) :
> there is no slot with name "modeling.id <http://modeling.id>" for
> this object of class "BIOMOD.models.out"
>
>
>
>
> #######################################################################
>
>
> > myBiomodModelOut
>
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> BIOMOD.models.out
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> Error en cat("\nModeling id :", object at modeling.id
> <mailto:object at modeling.id>, fill = .Options$width) :
> there is no slot with name "modeling.id <http://modeling.id>" for
> this object of class "BIOMOD.models.out"
>
>
>
> ###################################################################
>
> > sessionInfo()
> R version 3.0.0 (2013-04-03)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
>
> locale:
> [1] LC_COLLATE=Spanish_Spain.1252 LC_CTYPE=Spanish_Spain.1252
> LC_MONETARY=Spanish_Spain.1252 LC_NUMERIC=C
> [5] LC_TIME=Spanish_Spain.1252
>
> attached base packages:
> [1] parallel splines grid stats graphics grDevices utils
> datasets methods base
>
> other attached packages:
> [1] mgcv_1.7-22 MASS_7.3-26 foreign_0.8-53
> biomod2_2.1.27 pROC_1.5.4 plyr_1.8 rpart_4.1-1
> [8] randomForest_4.6-7 mda_0.4-2 class_7.3-7 gbm_2.1
> survival_2.37-4 nnet_7.3-6 rasterVis_0.20-07
> [15] hexbin_1.26.2 latticeExtra_0.6-24 RColorBrewer_1.0-5
> lattice_0.20-15 raster_2.1-25 sp_1.0-9 abind_1.4-0
>
> loaded via a namespace (and not attached):
> [1] Matrix_1.0-12 nlme_3.1-109 tools_3.0.0 zoo_1.7-10
>
More information about the Biomod-commits
mailing list