[R-sig-Geo] error in dudi.pca (adehabitat)

Mathieu Basille basille at biomserv.univ-lyon1.fr
Tue Apr 27 23:58:31 CEST 2010


The code seems OK (try to avoid the '=' as the attribution sign, and use 
always '<-' instead). Do you have access to a public (or not) ftp server 
that you could use temporarily for the occasion? Otherwise, you can use 
e.g. http://dl.free.fr/ (in French, but should be easy), where you can 
protect your files with a password.

I'm not sure I can debug this without the data...

Cheers,
Mathieu.


Consuelo Hermosilla a écrit :
> Dear Mathieu,
> 
> Thanks for your quick reply!!! :)
> 
> I thought that too, but then, why I'm able to plot the imported map? It 
> makes no sense, I wouldn't be able to plot it if there was an error 
> there, would I?
> 
> This was my code:
> 
> library(adehabitat)
> 
> chl= import.asc("chl-box_qt.asc", type ="numeric")
> sst = import.asc("sst-box_QT.asc", type ="numeric")
> dep = import.asc("dep-box_QT.asc", type ="numeric")
> euph = import.asc("euph-box_QT.asc", type ="numeric")
> OX0 = import.asc("OX0-box_QT.asc", type ="numeric")
> OX200 = import.asc("OX200-box_QT.asc", type ="numeric")
> OX50 = import.asc("OX50-box_QT.asc", type ="numeric")
> P0 = import.asc("P0-box_QT.asc", type ="numeric")
> P100 = import.asc("P100-box_QT.asc", type ="numeric")
> P125 = import.asc("P125-box_QT.asc", type ="numeric")
> P150 = import.asc("P150-box_QT.asc", type ="numeric")
> P200 = import.asc("P200-box_QT.asc", type ="numeric")
> pre = import.asc("pre-box_QT.asc", type ="numeric")
> 
> env_maps = as.kasc(list(chl, sst, dep, euph, OX0, OX200, OX50, P0, P100, 
> P125, P150, P200, pre))
> 
> managNAkasc (env_maps)  # just to check
> presence <- read.csv("presence.csv")
> octopus.hab <- data2enfa(env_maps, presence)
> pca.octopus <- dudi.pca(octopus.hab$tab, scannf=FALSE)
> 
> Can I attach files? How do you want me to provide data?
> 
> Consuelo
> 
> -------------
> Consuelo Hermosilla
> PhD student
> Departamento de Ecología y Biología Animal
> Departamento de Bioquímica, Genética e Inmunología, Área de Genética
> Facultad de Ciencias del Mar
> Campus de As Lagoas-Marcosende
> Universidad de Vigo
> 36310 Vigo
> SPAIN
> Mobile: +34 692 633 298
> 
> oooO
> (     ) Oooo
>    (   (     )
>   _)    )  /
>         (_/
> 
> Stop Gaza Massacre
> 
> 
> On Tue, Apr 27, 2010 at 11:31 PM, Mathieu Basille 
> <basille at biomserv.univ-lyon1.fr <mailto:basille at biomserv.univ-lyon1.fr>> 
> wrote:
> 
>     Dear Consuelo,
> 
>     I guess the error just propagates from the initial import, and has
>     nothing to do with dudi.pca (which is by the way from the ade4
>     package -- not directly related to adehabitat).
> 
>     Your approach otherwise seems (quite) OK. Unfortunately, you didn't
>     provide enough details to check. Could you provide the whole code,
>     with possibly some data, so that we can reproduce the problem?
> 
>     Cheers,
>     Mathieu.
> 
> 
> 
>     Consuelo Hermosilla a écrit :
> 
>         Hi folks,
> 
>         I'm trying to implement an ecological niche factor analysis with
>         octopus but
>         I have some problems. I think it is related to the fact I have
>         No-data
>         values. Since it's a marine species, I have land areas where I
>         have no-data
>         values. Can I have grids with no-data values?
> 
>         The thing is I'm able to import the ascii grid (using
>         import.asc) and I'm
>         even able to plot it (and see the image), so I guessed I have no
>         problems
>         with the no-data values. If I checked the grid, I got this:
> 
>         str(chl)
>          asc [1:1214, 1:761] NA NA NA NA NA NA NA NA NA NA ...
>          - attr(*, "xll")= num -18.6
>          - attr(*, "yll")= num 16.7
>          - attr(*, "cellsize")= num 0.05
>          - attr(*, "type")= chr "numeric"
> 
>         It looks wrong, but it's OK since my first values are indeed NA.
>         In fact,
>         besides the fact I'm able to plot it, I can calculate grid means
>         and other
>         stats, so I think the problem is not here. Then, when I grouped
>         all the
>         grids (with the as.kasc function), I got this:
> 
>         str(env_maps)
>         Classes ?kasc? and 'data.frame':        923854 obs. of  13
>         variables:
>          $ : num  NA NA NA NA NA NA NA NA NA NA ...
>          $ : num  NA NA NA NA NA NA NA NA NA NA ...
>          $ : num  NA NA NA NA NA NA NA NA NA NA ...
>          $ : num  NA NA NA NA NA NA NA NA NA NA ...
>          $ : num  NA NA NA NA NA NA NA NA NA NA ...
>          $ : num  NA NA NA NA NA NA NA NA NA NA ...
>          $ : num  NA NA NA NA NA NA NA NA NA NA ...
>          $ : num  NA NA NA NA NA NA NA NA NA NA ...
>          $ : num  NA NA NA NA NA NA NA NA NA NA ...
>          $ : num  NA NA NA NA NA NA NA NA NA NA ...
>          $ : num  NA NA NA NA NA NA NA NA NA NA ...
>          $ : num  NA NA NA NA NA NA NA NA NA NA ...
>          $ : num  NA NA NA NA NA NA NA NA NA NA ...
>          - attr(*, "cellsize")= num 0.05
>          - attr(*, "xll")= num -18.6
>          - attr(*, "yll")= num 16.7
>          - attr(*, "ncol")= int 1214
>          - attr(*, "nrow")= int 761
>          - attr(*, "type")= chr  "numeric" "numeric" "numeric" "numeric" ...
> 
>         Still looks wrong, but it shouldn't be. Then, I proceed with the
>         data2enfa
>         function, that seemed to work. But in the next step, when I was
>         calculating
>         the dudi.pca, it failed, with this error:
> 
>         Error in `rownames<-`(`*tmp*`, value = c("1", "2", "3", "4",
>         "5", "6",  :
>          attempt to set rownames on object with no dimensions
> 
>         I checked the data2enfa result and I got this:
> 
>         List of 4
>          $ tab  :'data.frame':  923854 obs. of  0 variables
>          $ pr   : int [1:923854] 0 0 0 0 0 0 0 0 0 0 ...
>          $ index: int [1:923854] 1 2 3 4 5 6 7 8 9 10 ...
>          $ attr :Class 'mapattr'  atomic [1:1] 0
>          .. ..- attr(*, "xll")= num -18.6
>          .. ..- attr(*, "yll")= num 16.7
>          .. ..- attr(*, "cellsize")= num 0.05
>          .. ..- attr(*, "nrow")= int 761
>          .. ..- attr(*, "ncol")= int 1214
>          - attr(*, "class")= chr "dataenfa"
> 
>         When I check the $tab, I got this:
> 
>         octopus.hab$tab
>         data frame with 0 columns and 923854 rows*
> 
>         *And I have no idea of what's wrong.... any ideas? do you
>         suggest anything?
>         Why do I have 0 columns and 923854 rows? Is that possible? Can
>         the data2enfa
>         funcion deal with no-data values?
> 
>         I tried the magagNAkasc, but doesn't work...
> 
>         managNAkasc (env_maps)
>         Raster map of class "kasc":
>         Cell size:  0.05
>         Number of rows:  761
>         Number of columns:  1214
> 
>         Variables measured:
>         1. : numeric
>         Error in .subset2(x, i, exact = exact) :
>          attempt to select less than one element
> 
>         I have tried in Windows Vista and Linux (both R 2.10.1 and
>         adehabitat v
>         1.83.
> 
>         I'd appreciate any help!!
> 
>         Thanks!!!
> 
>         Consuelo
> 
>                [[alternative HTML version deleted]]
> 
>         _______________________________________________
>         R-sig-Geo mailing list
>         R-sig-Geo at stat.math.ethz.ch <mailto:R-sig-Geo at stat.math.ethz.ch>
>         https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 
> 
>     -- 
> 
>     ~$ whoami
>     Mathieu Basille, Post-Doc
> 
>     ~$ locate
>     Laboratoire d'Écologie Comportementale et de Conservation de la Faune
>     + Centre d'Étude de la Forêt
>     Département de Biologie
>     Université Laval, Québec
> 
>     ~$ info
>     http://ase-research.org/basille
> 
>     ~$ fortune
>     ``If you can't win by reason, go for volume.''
>     Calvin, by Bill Watterson.
> 
> 

-- 

~$ whoami
Mathieu Basille, Post-Doc

~$ locate
Laboratoire d'Écologie Comportementale et de Conservation de la Faune
+ Centre d'Étude de la Forêt
Département de Biologie
Université Laval, Québec

~$ info
http://ase-research.org/basille

~$ fortune
``If you can't win by reason, go for volume.''
Calvin, by Bill Watterson.



More information about the R-sig-Geo mailing list