## Not run:
#
# # Extract residence events from the archived crocodile data
#
# # Load the crocodile dataset into the VTrack archive format
# data(crocs)
# Vcrocs <- ReadInputData(infile=crocs,
# iHoursToAdd=10,
# fAATAMS=FALSE,
# fVemcoDualSensor=FALSE,
# dateformat = NULL,
# sVemcoFormat='1.0')
#
# # Load and generate the direct distance matrix
# data(PointsDirect_crocs)
# DirectDM <- GenerateDirectDistance(PointsDirect_crocs)
#
# # Extract data for only transmitter #139
# T139 <- ExtractData(Vcrocs,sQueryTransmitterList = c("139"))
# T139_R <- ExtractUniqueValues(T139,5)
#
# # Extract residences and nonresidences events.
# # Events occur when >1 detection occurs at a receiver and detections
# # are less than 43200 seconds apart
# # The direct distance matrix is used for distance calculations
# T139Res<- RunResidenceExtraction(T139,
# "RECEIVERID",
# 2,
# 43200,
# sDistanceMatrix=DirectDM)
#
# # The residenceslog table
# T139log <- T139Res$residenceslog
# # The residences event file
# T139resid <- T139Res$residences
# # The nonresidences event file
# T139nonresid <- T139Res$nonresidences
#
# # The RESIDENCEEVENT number in the residences event table corresponds
# # to the RESIDENCEEVENT number in the residenceslog table
# subset(T139log,T139log$RESIDENCEEVENT==2)
# subset(T139resid, T139resid$RESIDENCEEVENT==2)
#
# subset(T139log,T139log$RESIDENCEEVENT==8)
# subset(T139resid, T139resid$RESIDENCEEVENT==8)
#
# # Scale duration spent at receivers into 4 bins: <1min, <1hr, <1day, >1day
# pchDURATION <- ifelse(T139resid$DURATION<60,0.1,
# ifelse(T139resid$DURATION<(60*60),0.5,
# ifelse(T139resid$DURATION<(60*60*24),1,3)))
#
# # For TRANSMITTERID 139 plot the detections against time for each RECEIVERID
# par(mfrow=c(1,1),las=1,bty="l")
# plot(as.Date(T139resid$STARTTIME),
# as.numeric(as.factor(
# as.numeric(as.character(T139resid$RECEIVERID)))),
# ylab="RECEIVERID",xlab="DATETIME",
# yaxt="n",pch=1,cex.axis=0.9,cex=pchDURATION,
# main=unique(T139resid$TRANSMITTER))
# axis(side=2,las=1, at=seq(1,length(T139_R),1),cex.axis=0.7,
# labels = T139_R[order(as.numeric(T139_R))])
#
# # Now plot the residence time at a receiver spatially and with
# # each point representing the duration spent at each receiver
# myresid1 <- subset(T139resid, T139resid$ENDREASON=="receiver")
# totalDur <- tapply(myresid1$DURATION,myresid1$RECEIVERID,sum)
# totalDurT <- data.frame(LOCATION=names(totalDur), DURATION=as.vector(totalDur))
# XYDuration <- merge(PointsDirect_crocs,totalDurT)
#
# plot(PointsDirect_crocs$LONGITUDE,PointsDirect_crocs$LATITUDE,
# pch=1,cex=0.5,col="grey40",
# xlim=c((min(PointsDirect_crocs$LONGITUDE)-0.01),(max(PointsDirect_crocs$LONGITUDE)+0.01)),
# ylim=c((min(PointsDirect_crocs$LATITUDE)-0.01),(max(PointsDirect_crocs$LATITUDE)+0.01)),
# xlab="Longitude",ylab="Latitude",
# main=unique(T139resid$TRANSMITTER))
# points(XYDuration$LONGITUDE,XYDuration$LATITUDE,
# cex=XYDuration$DURATION/500000, pch=16)
# ## End(Not run)
Run the code above in your browser using DataLab