[R] Error working dsm: Error in fix.by(by.x, x) : 'by' must specify a uniquely valid column
Milagros Antun
antunmilagros at gmail.com
Tue Jun 16 16:04:03 CEST 2015
Hello, I`m trying to use dsm package, *(library(Distance); library(dsm)*) ,
following Miller`s Appendix (
http://onlinelibrary.wiley.com/store/10.1111/2041-210X.12105/asset/supinfo/mee312105-sup-0001-AppendixS1.pdf?v=1&s=ced953b57365e5eb5753f0ad76dcc02c26918736
).
I work with three dataframes, whose str are:
*1) segdata:*
data.frame': 193 obs. of 17 variables:
$ Sample.Lab : int 1 2 3 4 5 6 7 8 9 10 ...
$ Transect.Label: Factor w/ 56 levels "1","100","101",..: 36 36 36 36 36
20 56 52 52 52 ...
$ Effort : int 1800 1800 1800 1800 1800 1800 1800 1800 1800 1800
...
$ x : num 4443636 4437817 4442085 4440564 4439117 ...
$ y : num 5267395 5271579 5268309 5269266 5270337 ...
$ ID_ESTRATO : int 3 2 3 2 2 2 2 2 4 2 ...
$ NDVI2010 : num 1813 1816 1804 1807 1816 ...
$ NDVI2011 : num 2007 1943 1935 1894 1893 ...
$ NDVI2012 : num 1705 1736 1686 1691 1729 ...
$ NDVI2013 : num 2206 2305 2145 2211 2279 ...
$ PROM_NDVI : num 2218 2313 2148 2206 2275 ...
$ DIST_PUEST : num 959 455 2652 3194 1394 ...
$ DIST_CUADR : num 1482.1 137.5 549.9 62.9 514.8 ...
$ DIST_MOLIN : num 794 5022 2519 4156 5715 ...
$ X_4326 : num -63.7 -63.8 -63.7 -63.7 -63.7 ...
$ Y_4326 : num -42.7 -42.7 -42.7 -42.7 -42.7 ...
$ O.KM2_2015 : num 64.1 34.6 43.4 44.4 46.6 ...
*2) obsdata:*
'data.frame': 399 obs. of 6 variables:
$ Especie. : Factor w/ 1 level "Oveja": 1 1 1 1 1 1 1 1 1 1 ...
$ size : int 3 1 5 18 6 2 6 3 5 2 ...
$ distance : int 210 178 65 210 250 37 72 350 380 320 ...
$ object : int 1 2 5 7 8 13 14 20 30 31 ...
$ Sample.Label: int 26 26 30 30 30 29 28 27 31 31 ...
$ Effort : num 1.8 1.8 1.8 1.8 1.8 1.8 1.8 1.8 1.8 1.8 ...
*3)disdata*
'data.frame': 399 obs. of 7 variables:
$ x : num 4418278 4418667 4421229 4421308 4421308 ...
$ y : num 5299140 5298846 5295963 5295805 5295805 ...
$ Especie.: Factor w/ 1 level "Oveja": 1 1 1 1 1 1 1 1 1 1 ...
$ size : int 3 1 5 18 6 2 6 3 5 2 ...
$ distance: int 210 178 65 210 250 37 72 350 380 320 ...
$ object : int 1 2 5 7 8 13 14 20 30 31 ...
$ Effort : num 1.8 1.8 1.8 1.8 1.8 1.8 1.8 1.8 1.8 1.8 ...
*First, I **fitted a detection function with the **script: *
*hr.model <-ds(distdata,truncation="10%",transect ="line",dht.group=
FALSE,key ="hr", convert.units = 1,adjustment =NULL) *
*And then, I tried to fit a **very simple model, with the script:*
*mod1<-dsm(count ~ s(x,y, k=6), ddf.obj=hr.model, segdata, obsdata, engine
= "gam",convert.units = 1, family = quasipoisson(link = "log"),group =
FALSE,gamma = 1.4,control = list(keepData = TRUE),availability =
1,segment.area = NULL, weights = NULL)*
*Here I made a mistake, because R show me an Error: *
*Error in fix.by <http://fix.by/>(by.x, x) : 'by' must specify a uniquely
valid column*
*Does anybody can help me? Thanks in advance!*
*Milagros*
--
Lic. Ma. de los Milagros Antún
Centro Nacional Patagónico-CONICET
Boulevard Brown 2915
9120 Puerto Madryn
Argentina
Tel. +54 (0) 280 4883184
Interno 1345
Fax +54 (0) 280 4883543
[[alternative HTML version deleted]]
More information about the R-help
mailing list