Habitat mask: write.table error

questions concerning anlysis/theory using program DENSITY and R package secr. Focus on spatially-explicit analysis.

Habitat mask: write.table error

Postby oconnell » Tue Jun 18, 2013 11:42 am

hi all,

I have been trying to work through this error for some time and have finally figured out why I am getting it. However, I do not know how to fix it.

I am trying to create habitat covariates to use in my analysis. I have a robust design (6 years, 8 occasions) hair snare mark-recapture study. there have been years where we have had to move the sites because of varies reasons. Therefore, I have to make 6 different files for each year then combine them R:
Code: Select all
PC1 = "PCTrapLayout_PC1.csv"
PC2 = "PCTrapLayout_PC2.csv"
PC3 = "PCTrapLayout_PC3.csv"
PC4 = "PCTrapLayout_PC4.csv"
PC5 = "PCTrapLayout_PC5.csv"
PC6 = "PCTrapLayout_PC6.csv"
alltrap=c(PC1, PC2, PC3, PC4, PC5, PC6)


So, I created my habitat polygon imported it into R, then created my mask:
Code: Select all
PCHabpoly <- readShapePoly('D2_Dissolve.shp')
PChabmask <- make.mask(traps(PCBearCH), buffer = 10000, poly = PCHabpoly, type='trapbuffer')


This is where the problem happens. This creates 6 different mask one for each year, and because traps were moved or not all traps were run each year each mask is a different size with a different number of points. When I go to write my table, I get this error:
Code: Select all
> write.table(PChabmask, file = "habitatxy.csv", sep = ",")
Error in data.frame(PC1 = list(x = c(621555.0859375, 623750.9453125, 625214.8515625,  :
  arguments imply differing number of rows: 1196, 1188, 773


The "differing number of rows" corresponds to the different number of points in each habitat mask.

I am stumped on what to do next and how to fix this. If anyone has dealt with issue and has suggests, it would be very much appreciated. Thank you in advance for your help.

kaitlin
oconnell
 
Posts: 4
Joined: Tue Mar 26, 2013 2:05 pm
Location: University of Tennessee

Re: Habitat mask: write.table error

Postby murray.efford » Tue Jun 18, 2013 1:34 pm

Hi Kaitlin
I'm not quite sure why you want to export the mask coordinates. If the goal is simply to attach covariate values for each mask point then addCovariates() is the way to go.

make.mask by default will make a different mask for each annual component of a traps object. However, if the trap layouts are in essentially the same area each year you can get by with a single mask based on the most complete layout, e.g.:
Code: Select all
PChabmask2 <- make.mask(traps(PCBearCH)[[2]], buffer = 10000, poly = PCHabpoly, type='trapbuffer')
if the second one is the most complete and covers all the others. Use a slightly larger buffer if necessary to be sure of coverage.

If you really want to write out each component of the multi-session mask then:
Code: Select all
for (i in 1:6)
write.table(PChabmask[[i]], file = paste("habitatxy",i,".csv", sep=""), sep = ",")


Murray
murray.efford
 
Posts: 712
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand


Return to analysis help

Who is online

Users browsing this forum: No registered users and 4 guests

cron