[R] Help_urgent_how to calculate mean and sd in biomod 2

Rui Barradas ruipbarradas at sapo.pt
Sat Oct 21 06:40:45 CEST 2017


Hello,

This is because myBiomodModelEval_55["ROC","Testing.data",,,] is a 
vector not an array or matrix. What the error message is saying is that 
dim() is not returning a value (it's length is not positive, since it 
cannot be negative length(dim(.)) must be zero). Try it.
Or see the class of those objects.

class(myBiomodModelEval_55["ROC","Testing.data",,,])
class(myBiomodModelEval_55["TSS","Testing.data",,,])


You do not apply(), simply do

mean(myBiomodModelEval_55["ROC","Testing.data",,,])

And the same for sd().

Hope this helps,

Rui Barradas

Em 21-10-2017 01:11, Lara Dutra Silva escreveu:
> Hello
>
> I am new in R. I am trying to implement Biomod 2 package.
>
> However, I have a doubt. I want to calculate the mean and sd of
> "Testing.data"
> (ROC and TSS)
>
>
>> # let's print the ROC scores of all selected models
>
>> myBiomodModelEval_55["ROC","Testing.data",,,]
>
>   RUN1  RUN2  RUN3  RUN4  RUN5  RUN6  RUN7  RUN8  RUN9 RUN10
>
> 0.938 0.938 0.926 0.931 0.939 0.918 0.920 0.914 0.935 0.919
>
>>
>
>> # let's print the TSS scores
>
>> myBiomodModelEval_55["TSS","Testing.data",,,]
>
>   RUN1  RUN2  RUN3  RUN4  RUN5  RUN6  RUN7  RUN8  RUN9 RUN10
>
> 0.746 0.763 0.717 0.758 0.754 0.704 0.700 0.725 0.742 0.721
>
>>
>
>
>
> I try to use "apply"
>
> apply(myBiomodModelEval_55["TSS","Testing.data",,,], 1, mean)
>
> apply(myBiomodModelEval_55["ROC","Testing.data",,,],1, mean)
>
> apply(myBiomodModelEval_55["ROC","Testing.data",,,], 1, sd)
>
> apply(myBiomodModelEval_55["TSS","Testing.data",,,], 1, sd)
>
>
>
> I can not figure it out because it runs error.
> The problem is in the dimension?
>
> Error in apply(myBiomodModelEval_55["TSS", "Testing.data", , , ], 1, mean) :
>
>    dim(X) must have a positive length
>
>>
>
>
> How can I solve this?
>
> This is the structure of object
>
>> dimnames(myBiomodModelEval_55)
> [[1]]
> [1] "ROC" "TSS"
>
> [[2]]
> [1] "Testing.data" "Cutoff"       "Sensitivity"  "Specificity"
>
> [[3]]
> [1] "GAM"
>
> [[4]]
>   [1] "RUN1"  "RUN2"  "RUN3"  "RUN4"  "RUN5"  "RUN6"  "RUN7"  "RUN8"  "RUN9"
> [10] "RUN10"
>
> [[5]]
> Acacia_AllData
>       "AllData"
>
>
> Regards,
> Silva
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list