[R-sig-Geo] Using the ENFA from adehabitatHS in R with sp classes

AGG18 at pitt.edu AGG18 at pitt.edu
Wed Aug 14 21:37:45 CEST 2013


Dear Mathieu,

Thank you for the assistance.

Upon executing the situation where I take the material of 'join' to
replace 'map' I receive an error:

> join<- cbind(bio1 at data, bio2 at data, bio3 at data, bio4 at data, bio5 at data,
bio6 at data, bio7 at data)
> tab <- slot(join, "data")
Error in slot(join, "data") :
  no slot of name "data" for this object of class "data.frame"

the description of what is compiled in the maps contain in 'join' are:

>head(join)
  bio1.asc bio2.asc bio3.asc bio4.asc bio5.asc bio6.asc bio7.asc
1       NA       NA       NA       NA       NA       NA       NA
2       NA       NA       NA       NA       NA       NA       NA
3       NA       NA       NA       NA       NA       NA       NA
4       NA       NA       NA       NA       NA       NA       NA
5       NA       NA       NA       NA       NA       NA       NA
6       NA       NA       NA       NA       NA       NA       NA
> class(join)
[1] "data.frame"


Do I need to create a slot or name an element 'data?'

Please advise further.

Cheers,
Alannie

> Dear Alannie,
>
> Obviously all these "data"s are confusing :)
> The 'enfa' example uses a dataset call 'lynxjura' (not 'data'), which is a
> list with several elements. One of these elements is the maps, with the
> name 'map' (singular!). This is what you want to achieve. This is simply a
> SpatialPixelsDataFrame, but as far as I can tell, a SpatialGridDataFrame
> will do too (if you want to know more about the differences between these
> two, check the sp vignette).
>
> So, following your example, just replace "map" by "join", and it should
> work. The 'slot(map, "data")' line extracts the data frame storing the
> data
> of the map, since the dudi.pca and enfa functions do not directly need the
> spatial attributes.
>
> Hope this helps,
> Mathieu.
>
>
> Le 08/14/2013 02:23 PM, alannie a écrit :
>> Hi folks!
>>
>> I have been having significant difficulty using the sp classes to
>> perform
>> the ENFA in R.
>> The objective of this posting is to inquire about how to "prepare data
>> for
>> the ENFA," which in previous versions of the software package adehabitat
>> was
>> carried out via 'data2enfa' and the 'dudi.pca' functions.
>>
>> I have been using the code:
>>
>> #Add table of coordinate locations
>>
>>> locs<-read.table("xybartsiifolia.csv", header=TRUE, sep=",")
>>
>> #Convert to class sp
>>
>>> xy.sp = SpatialPoints(locs)
>>
>> #Import .asc variable maps into R.
>>
>>> bio1<-read.asciigrid("bio1.asc", as.image = FALSE, plot.image = FALSE,
>> colname = basename("bio1.asc"), proj4string = CRS(as.character(NA)))
>>> bio2<-read.asciigrid("bio2.asc", as.image = FALSE, plot.image = FALSE,
>> colname = basename("bi



More information about the R-sig-Geo mailing list