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