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@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.
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo