diff --git a/R/mort.R b/R/mort.R index 0ba357e..6040431 100644 --- a/R/mort.R +++ b/R/mort.R @@ -4,8 +4,7 @@ #' derived from the dataset itself. #' #' @param data a dataframe of residence events. Residence events must include -#' tag ID, location name, start time, and duration. Residence events must also -#' include end time if `season` is provided. +#' tag ID, location name, start time, end time, and duration. #' @param type the method used to generate the residence events. Options are #' "mort", "actel", "glatos", "vtrack", or "manual". If "manual", then user #' must specify `ID`, `station`, `res.start`, `res.end`, `residences`, and `units`. @@ -66,6 +65,8 @@ #' residence events that is within the period of interest will be retained, #' and `residences` will be recalculated, using specified `units`. #' Default is `TRUE` +#' @param progress.bar option to display progress bar as function and called +#' functions are run. Default is TRUE. #' #' @return a dataframe with one row for each tag ID, including the date/time of #' the residence start when the potential mortality or expelled tag was identified. @@ -78,16 +79,18 @@ #' #' @examples #' morts_ex<-morts(data=events,type="mort",ID="ID", -#' station="Station.Name",method="any") +#' station="Station.Name",method="any",progress.bar=FALSE) +#' head(morts_ex) #' #'morts_ex_bw<-morts(data=events,type="mort",ID="ID", -#'station="Station.Name",method="any",backwards=TRUE) +#'station="Station.Name",method="any",backwards=TRUE,progress.bar=FALSE) +#'head(morts_ex_bw) morts<-function(data,type="mort",ID,station,res.start="auto",res.end="auto", method="all",units="auto",residences="auto", singles=TRUE,backwards=FALSE,drift="none",ddd=NULL, from.station=NULL, to.station=NULL,drift.cutoff=NULL, drift.units=NULL,season.start=NULL,season.end=NULL, - season.overlap=TRUE,morts.prev=NULL){ + season.overlap=TRUE,morts.prev=NULL,progress.bar=TRUE){ if (!(type %in% c("actel","glatos","manual","mort","vtrack"))){ stop("invalid type. Please enter valid type: 'actel', 'glatos', @@ -151,7 +154,8 @@ morts<-function(data,type="mort",ID,station,res.start="auto",res.end="auto", print("Extracting data from the period/season(s) of interest") data<-season(data=data,type=type,ID=ID,station=station,res.start=res.start,res.end=res.end, residences=residences,units=units,season.start=season.start, - season.end=season.end,overlap=season.overlap) + season.end=season.end,overlap=season.overlap, + progress.bar=progress.bar) } if (any(is.na(data[[station]]))){ @@ -192,13 +196,15 @@ morts<-function(data,type="mort",ID,station,res.start="auto",res.end="auto", res.start=res.start,res.end=res.end,residences=residences, units=units, ddd=ddd,from.station=from.station,to.station=to.station, - cutoff.units=drift.units,cutoff=drift.cutoff) + cutoff.units=drift.units,cutoff=drift.cutoff, + progress.bar=progress.bar) } else { data.resmax<-drift(data=data,type=type,ID=ID,station=station, res.start=res.start,res.end=res.end,residences=residences, units=units, - ddd=ddd,from.station=from.station,to.station=to.station) + ddd=ddd,from.station=from.station,to.station=to.station, + progress.bar=progress.bar) } drift.resmax<-TRUE if (method %in% c("all","cumulative")){ @@ -209,7 +215,8 @@ morts<-function(data,type="mort",ID,station,res.start="auto",res.end="auto", data<-drift(data=data,type=type,ID=ID,station=station, res.start=res.start,res.end=res.end,residences=residences, units=units, - ddd=ddd,from.station=from.station,to.station=to.station) + ddd=ddd,from.station=from.station,to.station=to.station, + progress.bar=progress.bar) } else { data<-data.resmax @@ -230,14 +237,16 @@ morts<-function(data,type="mort",ID,station,res.start="auto",res.end="auto", data.morts<-drift(data=data,type=type,ID=ID,station=station, res.start=res.start,res.end=res.end,residences=residences, units=units, - ddd=ddd,from.station=from.station,to.station=to.station) + ddd=ddd,from.station=from.station,to.station=to.station, + progress.bar=progress.bar) if (!is.null(drift.cutoff)){ print("Identifying drift residence events to be removed from identifying resmax threshold") data.resmax<-drift(data=data,type=type,ID=ID,station=station, res.start=res.start,res.end=res.end,residences=residences, units=units, ddd=ddd,from.station=from.station,to.station=to.station, - cutoff.units=drift.units,cutoff=drift.cutoff) + cutoff.units=drift.units,cutoff=drift.cutoff, + progress.bar=progress.bar) } else {data.resmax<-data.morts} drift.resmax<-FALSE @@ -246,7 +255,8 @@ morts<-function(data,type="mort",ID,station,res.start="auto",res.end="auto", data.full<-drift(data=data.full,type=type,ID=ID,station=station, res.start=res.start,res.end=res.end,residences=residences, units=units, - ddd=ddd,from.station=from.station,to.station=to.station) + ddd=ddd,from.station=from.station,to.station=to.station, + progress.bar=progress.bar) } print("Identifying last station change") sc1<-stationchange(data=data.morts,type=type,ID=ID,station=station,res.start=res.start, @@ -263,14 +273,16 @@ morts<-function(data,type="mort",ID,station,res.start="auto",res.end="auto", data.morts<-drift(data=data,type=type,ID=ID,station=station, res.start=res.start,res.end=res.end,residences=residences, units=units, - ddd=ddd,from.station=from.station,to.station=to.station) + ddd=ddd,from.station=from.station,to.station=to.station, + progress.bar=progress.bar) if (!is.null(drift.cutoff)){ print("Applying drift to identify resmax threshold") data.resmax<-drift(data=data,type=type,ID=ID,station=station, res.start=res.start,res.end=res.end,residences=residences, units=units, ddd=ddd,from.station=from.station,to.station=to.station, - cutoff.units=drift.units,cutoff=drift.cutoff) + cutoff.units=drift.units,cutoff=drift.cutoff, + progress.bar=progress.bar) } else { data.resmax<-data.morts @@ -281,7 +293,8 @@ morts<-function(data,type="mort",ID,station,res.start="auto",res.end="auto", data.full<-drift(data=data.full,type=type,ID=ID,station=station, res.start=res.start,res.end=res.end,residences=residences, units=units, - ddd=ddd,from.station=from.station,to.station=to.station) + ddd=ddd,from.station=from.station,to.station=to.station, + progress.bar=progress.bar) } print("Identifying last station change") sc1<-stationchange(data=data.morts,type=type,ID=ID,station=station,res.start=res.start, @@ -305,7 +318,9 @@ morts<-function(data,type="mort",ID,station,res.start="auto",res.end="auto", if (method=="last"){ # Note that not run for "all" or "any", because "last" is also captured with "any" print("Identifying mortalities for method='last'") - pb<-txtProgressBar(1,length(tag),style=3) + if (progress.bar==TRUE){ + pb<-txtProgressBar(1,length(tag),style=3) + } for (i in 1:length(tag)){ # Only run if ID not already in morts # If it is already in morts, it would be from infrequent function, which @@ -321,14 +336,18 @@ morts<-function(data,type="mort",ID,station,res.start="auto",res.end="auto", morts[nrow(morts)+1,]<-data.morts[j,] } } - setTxtProgressBar(pb,i) + if (progress.bar==TRUE){ + setTxtProgressBar(pb,i) + } } } if (method %in% c("any","all")){ # Identify all the residences longer than max.res # If they are during or after the last station change, then add them to morts print("Identifying mortalities for method='any'") - pb<-txtProgressBar(1,length(tag),style=3) + if (progress.bar==TRUE){ + pb<-txtProgressBar(1,length(tag),style=3) + } for (i in 1:length(tag)){ res.temp<-data.morts[data.morts[[ID]]==tag[i],] j<-which(res.temp[[residences]]>max.res& @@ -355,7 +374,9 @@ morts<-function(data,type="mort",ID,station,res.start="auto",res.end="auto", morts[nrow(morts)+1,]<-res.temp[j[k],] } } - setTxtProgressBar(pb,i) + if (progress.bar==TRUE){ + setTxtProgressBar(pb,i) + } } } } @@ -367,7 +388,9 @@ morts<-function(data,type="mort",ID,station,res.start="auto",res.end="auto", res.end=res.end,residences=residences,units=units, stnchange=sc1)[[residences]],na.rm=TRUE) print("Identifying mortalities for method='cumulative'") - pb<-txtProgressBar(1,nrow(sc2),style=3) + if (progress.bar==TRUE){ + pb<-txtProgressBar(1,nrow(sc2),style=3) + } for (i in 1:nrow(sc2)){ res.temp<-data.morts[data.morts[[ID]]==sc2[[ID]][i],] res.temp<-res.temp[order(res.temp[[res.start]]),] @@ -417,7 +440,9 @@ morts<-function(data,type="mort",ID,station,res.start="auto",res.end="auto", } } } - setTxtProgressBar(pb,i) + if (progress.bar==TRUE){ + setTxtProgressBar(pb,i) + } } } @@ -426,11 +451,15 @@ morts<-function(data,type="mort",ID,station,res.start="auto",res.end="auto", if (!is.null(morts.prev)){ if (nrow(morts)>nm){ new.morts<-unique(c(new.morts,seq((nm+1),nrow(morts),1))) - pb<-txtProgressBar(1,length(new.morts),style=3) + if (progress.bar==TRUE){ + pb<-txtProgressBar(1,length(new.morts),style=3) + } for (i in 1:length(new.morts)){ morts[i,]<-backwards(data=NULL,morts=morts[i,],ID=ID,station=station, res.start=res.start,stnchange=sc2) - setTxtProgressBar(pb,i) + if (progress.bar==TRUE){ + setTxtProgressBar(pb,i) + } } } } @@ -451,8 +480,7 @@ morts<-function(data,type="mort",ID,station,res.start="auto",res.end="auto", #' on a user-defined threshold and timeframe. #' #' @param data a dataframe of residence events. Residence events must include -#' tag ID, location name, start time, and duration. Residence events must also -#' include end time if `season` is provided. +#' tag ID, location name, start time, end time, and duration. #' @param type the method used to generate the residence events. Options are #' "mort", "actel", "glatos", "vtrack", or "manual". If "manual", then user #' must specify `ID`, `station`, `res.start`, `res.end`, `residences`, and `units`. @@ -514,6 +542,8 @@ morts<-function(data,type="mort",ID,station,res.start="auto",res.end="auto", #' @param drift.units the units of the cutoff. Options are "secs", "mins", "hours", #' "days", and "weeks". Recommended to be the same as used to generate #' residence events in `data`. +#' @param progress.bar option to display progress bar as function and called functions +#' are run. Default is TRUE. #' #' @details Example of `method="recent"`: if `threshold=10`, `threshold.units="mins"`, #' `recent.period=52` and `recent.units="weeks"` (1 year), an animal will be @@ -541,19 +571,23 @@ morts<-function(data,type="mort",ID,station,res.start="auto",res.end="auto", #' inf_recent<-infrequent(data=events,type="mort",ID="ID", #' station="Station.Name",method="recent", #' threshold=0.5,threshold.units="hours", -#' recent.period=52,recent.units="weeks") +#' recent.period=52,recent.units="weeks", +#' progress.bar=FALSE) +#' head(inf_recent) #' #' ## User-defined example #' inf_defined<-infrequent(data=events,type="mort",ID="ID", #' station="Station.Name",method="defined", #' threshold=0.5,threshold.units="hours", -#' start="2019-10-01",end="2020-06-01") +#' start="2019-10-01",end="2020-06-01", +#' progress.bar=FALSE) +#' head(inf_defined) infrequent<-function(data,type="mort",ID,station,res.start="auto", res.end="auto",residences="auto",units="auto", method,threshold,threshold.units=NULL,recent.period=NULL,recent.units=NULL, start=NULL,end=NULL,morts.prev=NULL,replace=FALSE,backwards=FALSE, ddd=NULL,from.station=NULL,to.station=NULL, - drift.cutoff=NULL,drift.units=NULL){ + drift.cutoff=NULL,drift.units=NULL,progress.bar=TRUE){ if (type %in% c("actel","vtrack")){ data<-extractres(data=data,type=type) @@ -621,7 +655,8 @@ infrequent<-function(data,type="mort",ID,station,res.start="auto", data<-drift(data=data,type=type,ID=ID,station=station, res.start=res.start,res.end=res.end,residences=residences, units=units, - ddd=ddd,from.station=from.station,to.station=to.station) + ddd=ddd,from.station=from.station,to.station=to.station, + progress.bar=progress.bar) data.morts<-data } else { @@ -630,12 +665,14 @@ infrequent<-function(data,type="mort",ID,station,res.start="auto", res.start=res.start,res.end=res.end,residences=residences, units=units, ddd=ddd,from.station=from.station,to.station=to.station, - cutoff=drift.cutoff,cutoff.units=drift.units) + cutoff=drift.cutoff,cutoff.units=drift.units, + progress.bar=progress.bar) print("Applying drift (no cutoff)") data.morts<-drift(data=data,type=type,ID=ID,station=station, res.start=res.start,res.end=res.end,residences=residences, units=units, - ddd=ddd,from.station=from.station,to.station=to.station) + ddd=ddd,from.station=from.station,to.station=to.station, + progress.bar=progress.bar) } } else {data.morts<-data} @@ -663,7 +700,9 @@ infrequent<-function(data,type="mort",ID,station,res.start="auto", stop("recent.units is not specified") } print("Identifying mortalities from infrequent detections") - pb<-txtProgressBar(1,length(tag),style=3) + if (progress.bar==TRUE){ + pb<-txtProgressBar(1,length(tag),style=3) + } for (i in 1:length(tag)){ if (is.null(morts.prev)| (!is.null(morts.prev)& @@ -795,7 +834,9 @@ infrequent<-function(data,type="mort",ID,station,res.start="auto", } } } - setTxtProgressBar(pb,i) + if (progress.bar==TRUE){ + setTxtProgressBar(pb,i) + } } } @@ -816,7 +857,9 @@ infrequent<-function(data,type="mort",ID,station,res.start="auto", if (!is(end,"POSIXt")){ stop("end is not in the format YYYY-mm-dd HH:MM:SS") } - pb<-txtProgressBar(1,length(tag),style=3) + if (progress.bar==TRUE){ + pb<-txtProgressBar(1,length(tag),style=3) + } for (i in 1:length(tag)){ if (is.null(morts.prev)| (!is.null(morts.prev)& @@ -888,7 +931,9 @@ infrequent<-function(data,type="mort",ID,station,res.start="auto", } } } - setTxtProgressBar(pb,i) + if (progress.bar==TRUE){ + setTxtProgressBar(pb,i) + } } } diff --git a/R/options.R b/R/options.R index 5ebc477..d388488 100644 --- a/R/options.R +++ b/R/options.R @@ -30,10 +30,12 @@ #' @examples #' morts<-morts(data=events,type="mort",ID="ID",station="Station.Name", #' method="any") +#' head(morts) #' #' # If station change not identified yet: #' morts_bw<-backwards(data=events,morts=morts,ID="ID", #' station="Station.Name",res.start="ResidenceStart") +#' head(morts_bw) #' #' # Identify station change first: #' station.change<-stationchange(data=events,type="mort", @@ -42,6 +44,7 @@ #' morts_bw<-backwards(data=events,morts=morts,ID="ID", #' station="Station.Name",res.start="ResidenceStart", #' stnchange=station.change) +#' head(morts_bw) backwards<-function(data,morts,ID,station,res.start,stnchange=NULL){ if (any(data[[station]]=="Break")){ warning("Either a station name was 'Break' or data included seasonal @@ -137,13 +140,19 @@ backwards<-function(data,morts,ID,station,res.start,stnchange=NULL){ #' @export #' #' @examples -#' drift.events<-drift(data=events,type="mort",ID="ID", -#' station="Station.Name",ddd=ddd,from.station="From",to.station="To") +#' # With no drift: +#' head(events) +#' +#' drift.events<-drift(data=events[events$ID=="A",],type="mort",ID="ID", +#' station="Station.Name",ddd=ddd,from.station="From",to.station="To", +#' progress.bar=FALSE) +#' head(drift.events) #' #' # With cutoff: -#' drift.events<-drift(data=events,type="mort",ID="ID", +#' drift.events<-drift(data=events[events$ID=="A",],type="mort",ID="ID", #' station="Station.Name",ddd=ddd,from.station="From",to.station="To", -#' cutoff=1,cutoff.units="days") +#' cutoff=1,cutoff.units="days",progress.bar=FALSE) +#' head(drift.events) drift<-function(data,type,ID,station,res.start="auto",res.end="auto", residences="auto",units="auto",ddd,from.station,to.station, cutoff=NULL,cutoff.units=NULL,progress.bar=TRUE){ @@ -301,7 +310,7 @@ drift<-function(data,type,ID,station,res.start="auto",res.end="auto", #' residence events that is within the period of interest will be retained, #' and `residences` will be recalculated, using specified `units`. #' Default is `TRUE`. -#' @param progressbar option to display progress bar as function is run. Default +#' @param progress.bar option to display progress bar as function is run. Default #' is TRUE. #' #' @return a dataframe in the same format as the input data, with residence @@ -311,16 +320,19 @@ drift<-function(data,type,ID,station,res.start="auto",res.end="auto", #' @examples #' # Seasons in format dd-mm #' season.events<-season(data=events,type="mort",ID="ID", -#' station="Station.Name",season.start="01-06",season.end="31-10") +#' station="Station.Name",season.start="01-06",season.end="31-10", +#' progress.bar=FALSE) +#' head(season.events) #' #' # Seasons in format YYYY-mm-dd HH:MM:SS #' season.start<-c("2003-06-15","2004-06-21") #' season.end<-c("2003-10-15","2004-10-30") #' season.events<-season(data=events,type="mort",ID="ID", -#' station="Station.Name",season.start=season.start,season.end=season.end) +#' station="Station.Name",season.start=season.start,season.end=season.end,progress.bar=FALSE) +#' head(season.events) season<-function(data,type="mort",ID,station,res.start="auto",res.end="auto", residences="auto",units="auto",season.start, - season.end,overlap=TRUE,progressbar=TRUE){ + season.end,overlap=TRUE,progress.bar=TRUE){ if (type %in% c("actel","vtrack")){ data<-extractres(data=data,type=type) @@ -423,11 +435,11 @@ season<-function(data,type="mort",ID,station,res.start="auto",res.end="auto", data.season<-data[0,] for (i in 1:length(season.start)){ - if (progressbar==TRUE){ + if (progress.bar==TRUE){ print(paste("season/period",i,"of",length(season.start))) } if (length(tag)>1){ - if (progressbar==TRUE){ + if (progress.bar==TRUE){ pb<-txtProgressBar(1,length(tag),style=3) } } @@ -471,7 +483,7 @@ season<-function(data,type="mort",ID,station,res.start="auto",res.end="auto", } data.season<-rbind(data.season,data.temp) if (length(tag)>1){ - if (progressbar==TRUE){ + if (progress.bar==TRUE){ setTxtProgressBar(pb,j) } } diff --git a/R/plot.R b/R/plot.R index f0c9e3e..b7cd23d 100644 --- a/R/plot.R +++ b/R/plot.R @@ -4,8 +4,7 @@ #' mortalities. Plotting uses ggplot2. Interactive option also uses plotly. #' #' @param data a dataframe of residence events. Residence events must include -#' tag ID, location name, start time, and end time. Residence events must also -#' include duration if making an interactive plot. +#' tag ID, location name, start time, and end time. #' @param type the method used to generate the residence events. Options are #' "mort", "actel", "glatos", "vtrack", or "manual". #' @param ID a string of the name of the column in `data` that holds the tag or @@ -45,7 +44,7 @@ #' `facet.by="year"`. #' @param facet.by option to facet by "season" (as defined with `season.start` #' and `season.end`) or "year". Default is "season". -#' @param progressbar option to display progress bar as function is run. Default +#' @param progress.bar option to display progress bar as function is run. Default #' is TRUE. #' #' @return a ggplot2 plot. Additional arguments (e.g., formatting axes, @@ -57,19 +56,21 @@ #' #' @examples #' plot<-mortsplot(data=events,type="mort",ID="ID",station="Station.Name") +#' plot #' #' # With mortalities plotted over residences: #' morts<-morts(data=events,type="mort",ID="ID",station="Station.Name", -#' method="any") +#' method="any",progress.bar=FALSE) #' #' plot<-mortsplot(data=events,type="mort",ID="ID",station="Station.Name", #' morts=morts) +#' plot mortsplot<-function(data,type,ID,station,res.start="auto",res.end="auto", morts=NULL,singles=TRUE,interactive=FALSE,residences=NULL, units=NULL, season.start=NULL,season.end=NULL,facet=FALSE, facet.axis="x",facet.by="season", - progressbar=TRUE){ + progress.bar=TRUE){ if (!requireNamespace("ggplot2", quietly = TRUE)) { stop("Package \"ggplot2\" must be installed to use this function.", @@ -175,7 +176,7 @@ mortsplot<-function(data,type,ID,station,res.start="auto",res.end="auto", if (units=="auto"){ units<-autofield(type=type,field="units",data=data) } - if (progressbar==TRUE){ + if (progress.bar==TRUE){ print("Extracting data from the period/season(s) of interest") } if (is.null(season.start)&is.null(season.end)&facet.by=="year"){ @@ -184,7 +185,7 @@ mortsplot<-function(data,type,ID,station,res.start="auto",res.end="auto", } data<-season(data=data,type=type,ID=ID,station=station,res.start=res.start,res.end=res.end, residences=residences,units=units,season.start=season.start, - season.end=season.end,overlap=FALSE,progressbar=FALSE) + season.end=season.end,overlap=FALSE,progress.bar=progress.bar) data<-data[data[[station]]!="Break",] if (!is(season.start,"POSIXt")){ try(season.start<-as.POSIXct(season.start,tz="UTC"),silent=TRUE) diff --git a/R/residences.R b/R/residences.R index 10d5cb3..08e9667 100644 --- a/R/residences.R +++ b/R/residences.R @@ -13,6 +13,8 @@ #' @param ID a string of the name of the column in `data` that holds the tag or sample IDs. #' @param datetime a string of the name of the column in `data` that holds the date and time. #' @param station a string of the name of the column in `data` that holds the station name or receiver location. +#' @param progress.bar option to display progress bar as residences are generated. +#' Default is TRUE. #' #' @return A data frame with one row for each residence event, including date/time of #' residence start, date/time of residence end, and duration of residence event. All @@ -23,10 +25,12 @@ #' @importFrom utils setTxtProgressBar txtProgressBar #' #' @examples -#' res.events<-residences(data=detections,ID="ID",station="Station.Name", -#' datetime="DateTimeUTC",cutoff=1,units="days") +#' head(detections) +#' res.events<-residences(data=detections[1:500,],ID="ID",station="Station.Name", +#' datetime="DateTimeUTC",cutoff=1,units="days",progress.bar=FALSE) +#' head(res.events) -residences<-function(data,ID,station,datetime,cutoff,units){ +residences<-function(data,ID,station,datetime,cutoff,units,progress.bar=TRUE){ # Create list of unique IDs tag<-unique(na.omit(data[[ID]])) @@ -51,7 +55,9 @@ residences<-function(data,ID,station,datetime,cutoff,units){ # Set up res res<-cbind(data[0,],ResidenceEnd=as.POSIXct(as.character())) - pb<-txtProgressBar(1,length(tag),style=3) + if (progress.bar==TRUE){ + pb<-txtProgressBar(1,length(tag),style=3) + } for (i in 1:length(tag)){ # Subset by ID res.sub<-data[data[[ID]]==tag[i],] @@ -109,7 +115,9 @@ residences<-function(data,ID,station,datetime,cutoff,units){ break } } - setTxtProgressBar(pb,i) + if (progress.bar==TRUE){ + setTxtProgressBar(pb,i) + } } colnames(res)[colnames(res)==datetime]<-"ResidenceStart" attributes(res$ResidenceStart)$tzone<-attributes(data[[datetime]])$tzone diff --git a/R/review.R b/R/review.R index 6bfdedc..ccfbe0a 100644 --- a/R/review.R +++ b/R/review.R @@ -4,7 +4,7 @@ #' alive. #' #' @param morts a dataframe with previously flagged mortalities. Format does -#' not need to match `new.data`, but the names and formats of `ID`, `station`, +#' not need to match `new.data` exactly, but the names and formats of `ID`, `station`, #' and `res.start` fields must match in all input dataframes. #' @param new.data a dataframe of new residence events (i.e., generated from #' detection data that were not included in earlier `mort` analyses). @@ -37,6 +37,8 @@ #' @param residences an optional character string with the name of the column #' in `morts` and `new.data` that holds the duration of the residence events. #' Only needed if drift is applied. +#' @param progress.bar option to display progress bar as function and called +#' functions are run. Default is TRUE. #' #' @return A dataframe with one row for each tag ID from `morts` #' with a station/location change that was identified @@ -49,13 +51,14 @@ #' #' @examples #' morts<-morts(data=events,type="mort",ID="ID",station="Station.Name", -#' method="any") +#' method="any",progress.bar=FALSE) #' #' undead<-review(morts=morts,new.data=new.data, -#' type="mort",ID="ID",station="Station.Name") +#' type="mort",ID="ID",station="Station.Name",progress.bar=FALSE) review<-function(morts,new.data,old.data=NULL,type,ID,station,res.start="auto", res.end=NULL,residences=NULL,units=NULL, - ddd=NULL,from.station=NULL,to.station=NULL){ + ddd=NULL,from.station=NULL,to.station=NULL, + progress.bar=TRUE){ if (type %in% c("actel","vtrack")){ new.data<-extractres(data=new.data,type=type) @@ -199,7 +202,7 @@ review<-function(morts,new.data,old.data=NULL,type,ID,station,res.start="auto", res.start=res.start,res.end=res.end, ddd=ddd,from.station=from.station,to.station=to.station, residences=residences, - units=units) + units=units,progress.bar=progress.bar) for (i in 1:nrow(morts)){ res.temp<-data[data[[ID]]==morts[[ID]][i],] j<-1 diff --git a/R/stationchange.R b/R/stationchange.R index b2d4921..41399f8 100644 --- a/R/stationchange.R +++ b/R/stationchange.R @@ -33,7 +33,7 @@ #' @param to.station a string of the name of the column in `ddd` that contains #' the station/location names where drifting detections may move to. Must #' be identical to the station/location names in `data`. -#' @param progressbar option to display progress bar as function is run. Default +#' @param progress.bar option to display progress bar as function is run. Default #' is TRUE. #' #' @return a dataframe with one row for each tag ID, including the date/time of @@ -44,11 +44,12 @@ #' @export #' #' @examples -#' stn.change<-stationchange(data=events,type="mort",ID="ID",station="Station.Name") +#' stn.change<-stationchange(data=events,type="mort",ID="ID",station="Station.Name",progress.bar=FALSE) +#' head(stn.change) stationchange<-function(data,type="mort",ID,station,res.start="auto", res.end="auto",residences="auto", singles=TRUE,drift=FALSE,ddd=NULL,units=NULL,from.station=NULL, - to.station=NULL,progressbar=TRUE){ + to.station=NULL,progress.bar=TRUE){ if (type %in% c("actel","vtrack")&is(data,"list")){ data<-extractres(data=data,type=type) @@ -92,7 +93,7 @@ stationchange<-function(data,type="mort",ID,station,res.start="auto", if (drift==FALSE& !is(data[[station]],"list")){ - if (progressbar==TRUE){ + if (progress.bar==TRUE){ pb<-txtProgressBar(1,length(tag),style=3) } for (i in 1:length(tag)){ @@ -133,7 +134,7 @@ stationchange<-function(data,type="mort",ID,station,res.start="auto", else if (nrow(res.temp)==1){ stn.change[nrow(stn.change)+1,]<-res.temp[1,] } - if (progressbar==TRUE){ + if (progress.bar==TRUE){ setTxtProgressBar(pb,i) } } @@ -143,7 +144,8 @@ stationchange<-function(data,type="mort",ID,station,res.start="auto", if (drift==TRUE){ data.drift<-drift(data=data,type=type,ID=ID,station=station, res.start=res.start,res.end=res.end,residences=residences, - units=units,ddd=ddd,from.station=from.station,to.station=to.station) + units=units,ddd=ddd,from.station=from.station,to.station=to.station, + progress.bar=progress.bar) } else {data.drift<-data} pb<-txtProgressBar(1,length(tag),style=3) @@ -199,8 +201,7 @@ stationchange<-function(data,type="mort",ID,station,res.start="auto", #' before a station change (i.e., the animal can be assumed to be alive) #' #' @param data a dataframe of residence events. Residence events must include -#' tag ID, location name, start time, and duration. Residence events must also -#' include end time if `season` is provided. +#' tag ID, location name, start time, and duration. #' @param ID a string of the name of the column in `data` that holds the tag or #' sample IDs. #' @param station a string of the name of the column in `data` that holds the @@ -213,7 +214,7 @@ stationchange<-function(data,type="mort",ID,station,res.start="auto", #' recent station or location change. Must use the same column names as `data`. #' @param drift indicates if drift residence events should be included in #' determining the maximum residence duration -#' @param progressbar option to display progress bar as function is run. Default +#' @param progress.bar option to display progress bar as function is run. Default #' is TRUE. #' #' @return a dataframe with the residence information for the longest residence @@ -223,16 +224,17 @@ stationchange<-function(data,type="mort",ID,station,res.start="auto", #' @examples #' # Identify most recent station change #' station.change<-stationchange(data=events,type="mort",ID="ID", -#' station="Station.Name") +#' station="Station.Name",progress.bar=FALSE) #' #' longest_res_events<-resmax(data=events,ID="ID",station="Station.Name", #' res.start="ResidenceStart",residences="ResidenceLength.days", -#' stnchange=station.change) +#' stnchange=station.change,progress.bar=FALSE) +#' head(longest_res_events) resmax<-function(data,ID,station,res.start, - residences,stnchange,drift=FALSE,progressbar=TRUE){ + residences,stnchange,drift=FALSE,progress.bar=TRUE){ res.max<-data[0,] - if (progressbar==TRUE){ + if (progress.bar==TRUE){ pb<-txtProgressBar(1,nrow(stnchange),style=3) } for (i in 1:nrow(stnchange)){ @@ -259,7 +261,7 @@ resmax<-function(data,ID,station,res.start, } } } - if (progressbar==TRUE){ + if (progress.bar==TRUE){ setTxtProgressBar(pb,i) } } @@ -277,8 +279,7 @@ resmax<-function(data,ID,station,res.start, #' stations/locations. #' #' @param data a dataframe of residence events. Residence events must include -#' tag ID, location name, start time, and duration. Residence events must also -#' include end time if `season` is provided. +#' tag ID, location name, start time, and duration. #' @param ID a string of the name of the column in `data` that holds the tag or #' sample IDs. #' @param station a string of the name of the column in `data` that holds the @@ -292,7 +293,7 @@ resmax<-function(data,ID,station,res.start, #' @param units units of the duration of the residence events in `data`. #' @param stnchange a dataframe with the start time and location of the most #' recent station or location change. Must use the same column names as `data`. -#' @param progressbar option to display progress bar as function is run. Default +#' @param progress.bar option to display progress bar as function is run. Default #' is TRUE. #' #' @return a dataframe with the cumulative residence information for each @@ -303,18 +304,18 @@ resmax<-function(data,ID,station,res.start, #' #' @examples #' # Identify most recent station change -#' station.change<-stationchange(data=events,type="mort",ID="ID", -#' station="Station.Name") +#' station.change<-stationchange(data=events[events$ID=="A",],type="mort", +#' ID="ID",station="Station.Name",progress.bar=FALSE) #' -#' cumulative_events<-resmaxcml(data=events,ID="ID",station="Station.Name", -#' res.start="ResidenceStart",res.end="ResidenceEnd", +#' cumulative_events<-resmaxcml(data=events[events$ID=="A",],ID="ID", +#' station="Station.Name",res.start="ResidenceStart",res.end="ResidenceEnd", #' residences="ResidenceLength.days",units="days", -#' stnchange=station.change) +#' stnchange=station.change,progress.bar=FALSE) resmaxcml<-function(data,ID,station,res.start,res.end, - residences,units,stnchange,progressbar=TRUE){ + residences,units,stnchange,progress.bar=TRUE){ res.maxcml<-data[0,] - if (progressbar==TRUE){ + if (progress.bar==TRUE){ pb<-txtProgressBar(1,nrow(stnchange),style=3) } for (i in 1:nrow(stnchange)){ @@ -401,7 +402,7 @@ resmaxcml<-function(data,ID,station,res.start,res.end, else {break} } } - if (progressbar==TRUE){ + if (progress.bar==TRUE){ setTxtProgressBar(pb,i) } } diff --git a/man/backwards.Rd b/man/backwards.Rd index 0a26ced..8a80c6a 100644 --- a/man/backwards.Rd +++ b/man/backwards.Rd @@ -43,10 +43,12 @@ station/location has not changed. \examples{ morts<-morts(data=events,type="mort",ID="ID",station="Station.Name", method="any") +head(morts) # If station change not identified yet: morts_bw<-backwards(data=events,morts=morts,ID="ID", station="Station.Name",res.start="ResidenceStart") +head(morts_bw) # Identify station change first: station.change<-stationchange(data=events,type="mort", @@ -55,4 +57,5 @@ ID="ID",station="Station.Name") morts_bw<-backwards(data=events,morts=morts,ID="ID", station="Station.Name",res.start="ResidenceStart", stnchange=station.change) +head(morts_bw) } diff --git a/man/drift.Rd b/man/drift.Rd index 1ffa05d..089ddeb 100644 --- a/man/drift.Rd +++ b/man/drift.Rd @@ -76,11 +76,17 @@ Identifies sequential residence events where detected movement between stations may be due to drifting of an expelled tag or dead animal. } \examples{ -drift.events<-drift(data=events,type="mort",ID="ID", -station="Station.Name",ddd=ddd,from.station="From",to.station="To") +# With no drift: +head(events) + +drift.events<-drift(data=events[events$ID=="A",],type="mort",ID="ID", +station="Station.Name",ddd=ddd,from.station="From",to.station="To", +progress.bar=FALSE) +head(drift.events) # With cutoff: -drift.events<-drift(data=events,type="mort",ID="ID", +drift.events<-drift(data=events[events$ID=="A",],type="mort",ID="ID", station="Station.Name",ddd=ddd,from.station="From",to.station="To", -cutoff=1,cutoff.units="days") +cutoff=1,cutoff.units="days",progress.bar=FALSE) +head(drift.events) } diff --git a/man/infrequent.Rd b/man/infrequent.Rd index 133e99f..7b19e04 100644 --- a/man/infrequent.Rd +++ b/man/infrequent.Rd @@ -27,13 +27,13 @@ infrequent( from.station = NULL, to.station = NULL, drift.cutoff = NULL, - drift.units = NULL + drift.units = NULL, + progress.bar = TRUE ) } \arguments{ \item{data}{a dataframe of residence events. Residence events must include -tag ID, location name, start time, and duration. Residence events must also -include end time if \code{season} is provided.} +tag ID, location name, start time, end time, and duration.} \item{type}{the method used to generate the residence events. Options are "mort", "actel", "glatos", "vtrack", or "manual". If "manual", then user @@ -117,6 +117,9 @@ to generate residence events in \code{data}.} \item{drift.units}{the units of the cutoff. Options are "secs", "mins", "hours", "days", and "weeks". Recommended to be the same as used to generate residence events in \code{data}.} + +\item{progress.bar}{option to display progress bar as function and called functions +are run. Default is TRUE.} } \value{ if \code{morts=NULL}, a dataframe with one row for each tag ID, including the date/time of @@ -150,11 +153,15 @@ minutes between 01 October 2019 and 01 June 2020. inf_recent<-infrequent(data=events,type="mort",ID="ID", station="Station.Name",method="recent", threshold=0.5,threshold.units="hours", -recent.period=52,recent.units="weeks") +recent.period=52,recent.units="weeks", +progress.bar=FALSE) +head(inf_recent) ## User-defined example inf_defined<-infrequent(data=events,type="mort",ID="ID", station="Station.Name",method="defined", threshold=0.5,threshold.units="hours", -start="2019-10-01",end="2020-06-01") +start="2019-10-01",end="2020-06-01", +progress.bar=FALSE) +head(inf_defined) } diff --git a/man/morts.Rd b/man/morts.Rd index c60d00a..a2bddb6 100644 --- a/man/morts.Rd +++ b/man/morts.Rd @@ -25,13 +25,13 @@ morts( season.start = NULL, season.end = NULL, season.overlap = TRUE, - morts.prev = NULL + morts.prev = NULL, + progress.bar = TRUE ) } \arguments{ \item{data}{a dataframe of residence events. Residence events must include -tag ID, location name, start time, and duration. Residence events must also -include end time if \code{season} is provided.} +tag ID, location name, start time, end time, and duration.} \item{type}{the method used to generate the residence events. Options are "mort", "actel", "glatos", "vtrack", or "manual". If "manual", then user @@ -112,6 +112,9 @@ Default is \code{TRUE}} \item{morts.prev}{a dataframe containing potential mortalities. The dataframe must have the same columns and in the same order as \code{data}.} +\item{progress.bar}{option to display progress bar as function and called +functions are run. Default is TRUE.} + \item{season}{a dataframe with start and end dates of the season(s) of interest} } \value{ @@ -128,8 +131,10 @@ derived from the dataset itself. } \examples{ morts_ex<-morts(data=events,type="mort",ID="ID", -station="Station.Name",method="any") +station="Station.Name",method="any",progress.bar=FALSE) +head(morts_ex) morts_ex_bw<-morts(data=events,type="mort",ID="ID", -station="Station.Name",method="any",backwards=TRUE) +station="Station.Name",method="any",backwards=TRUE,progress.bar=FALSE) +head(morts_ex_bw) } diff --git a/man/mortsplot.Rd b/man/mortsplot.Rd index 91a3cbc..2267161 100644 --- a/man/mortsplot.Rd +++ b/man/mortsplot.Rd @@ -21,13 +21,12 @@ mortsplot( facet = FALSE, facet.axis = "x", facet.by = "season", - progressbar = TRUE + progress.bar = TRUE ) } \arguments{ \item{data}{a dataframe of residence events. Residence events must include -tag ID, location name, start time, and end time. Residence events must also -include duration if making an interactive plot.} +tag ID, location name, start time, and end time.} \item{type}{the method used to generate the residence events. Options are "mort", "actel", "glatos", "vtrack", or "manual".} @@ -83,7 +82,7 @@ and \code{season.end} must be provided.} \item{facet.by}{option to facet by "season" (as defined with \code{season.start} and \code{season.end}) or "year". Default is "season".} -\item{progressbar}{option to display progress bar as function is run. Default +\item{progress.bar}{option to display progress bar as function is run. Default is TRUE.} } \value{ @@ -98,11 +97,13 @@ mortalities. Plotting uses ggplot2. Interactive option also uses plotly. } \examples{ plot<-mortsplot(data=events,type="mort",ID="ID",station="Station.Name") +plot # With mortalities plotted over residences: morts<-morts(data=events,type="mort",ID="ID",station="Station.Name", -method="any") +method="any",progress.bar=FALSE) plot<-mortsplot(data=events,type="mort",ID="ID",station="Station.Name", morts=morts) +plot } diff --git a/man/residences.Rd b/man/residences.Rd index 55f9d88..ed7971a 100644 --- a/man/residences.Rd +++ b/man/residences.Rd @@ -4,7 +4,7 @@ \alias{residences} \title{Generate residence events} \usage{ -residences(data, ID, station, datetime, cutoff, units) +residences(data, ID, station, datetime, cutoff, units, progress.bar = TRUE) } \arguments{ \item{data}{a data frame of detection data.} @@ -20,6 +20,9 @@ be considered a single residence event.} \item{units}{the units of the cutoff. These will also be the units used to calculate the duration of the residence events. Options are "secs", "mins", "hours", "days", and "weeks".} + +\item{progress.bar}{option to display progress bar as residences are generated. +Default is TRUE.} } \value{ A data frame with one row for each residence event, including date/time of @@ -37,6 +40,8 @@ appears and after the progress bar has reached 100\%, which may be substantial depending on the size of the telemetry dataset. } \examples{ -res.events<-residences(data=detections,ID="ID",station="Station.Name", -datetime="DateTimeUTC",cutoff=1,units="days") +head(detections) +res.events<-residences(data=detections[1:500,],ID="ID",station="Station.Name", +datetime="DateTimeUTC",cutoff=1,units="days",progress.bar=FALSE) +head(res.events) } diff --git a/man/resmax.Rd b/man/resmax.Rd index 104422c..f4f34d1 100644 --- a/man/resmax.Rd +++ b/man/resmax.Rd @@ -12,13 +12,12 @@ resmax( residences, stnchange, drift = FALSE, - progressbar = TRUE + progress.bar = TRUE ) } \arguments{ \item{data}{a dataframe of residence events. Residence events must include -tag ID, location name, start time, and duration. Residence events must also -include end time if \code{season} is provided.} +tag ID, location name, start time, and duration.} \item{ID}{a string of the name of the column in \code{data} that holds the tag or sample IDs.} @@ -38,7 +37,7 @@ recent station or location change. Must use the same column names as \code{data} \item{drift}{indicates if drift residence events should be included in determining the maximum residence duration} -\item{progressbar}{option to display progress bar as function is run. Default +\item{progress.bar}{option to display progress bar as function is run. Default is TRUE.} } \value{ @@ -52,9 +51,10 @@ before a station change (i.e., the animal can be assumed to be alive) \examples{ # Identify most recent station change station.change<-stationchange(data=events,type="mort",ID="ID", -station="Station.Name") +station="Station.Name",progress.bar=FALSE) longest_res_events<-resmax(data=events,ID="ID",station="Station.Name", res.start="ResidenceStart",residences="ResidenceLength.days", -stnchange=station.change) +stnchange=station.change,progress.bar=FALSE) +head(longest_res_events) } diff --git a/man/resmaxcml.Rd b/man/resmaxcml.Rd index f34981c..cd5feb8 100644 --- a/man/resmaxcml.Rd +++ b/man/resmaxcml.Rd @@ -13,13 +13,12 @@ resmaxcml( residences, units, stnchange, - progressbar = TRUE + progress.bar = TRUE ) } \arguments{ \item{data}{a dataframe of residence events. Residence events must include -tag ID, location name, start time, and duration. Residence events must also -include end time if \code{season} is provided.} +tag ID, location name, start time, and duration.} \item{ID}{a string of the name of the column in \code{data} that holds the tag or sample IDs.} @@ -41,7 +40,7 @@ that holds the duration of the residence events.} \item{stnchange}{a dataframe with the start time and location of the most recent station or location change. Must use the same column names as \code{data}.} -\item{progressbar}{option to display progress bar as function is run. Default +\item{progress.bar}{option to display progress bar as function is run. Default is TRUE.} } \value{ @@ -60,11 +59,11 @@ stations/locations. } \examples{ # Identify most recent station change -station.change<-stationchange(data=events,type="mort",ID="ID", -station="Station.Name") +station.change<-stationchange(data=events[events$ID=="A",],type="mort", +ID="ID",station="Station.Name",progress.bar=FALSE) -cumulative_events<-resmaxcml(data=events,ID="ID",station="Station.Name", -res.start="ResidenceStart",res.end="ResidenceEnd", +cumulative_events<-resmaxcml(data=events[events$ID=="A",],ID="ID", +station="Station.Name",res.start="ResidenceStart",res.end="ResidenceEnd", residences="ResidenceLength.days",units="days", -stnchange=station.change) +stnchange=station.change,progress.bar=FALSE) } diff --git a/man/review.Rd b/man/review.Rd index 39d1d2f..5159e14 100644 --- a/man/review.Rd +++ b/man/review.Rd @@ -17,12 +17,13 @@ review( units = NULL, ddd = NULL, from.station = NULL, - to.station = NULL + to.station = NULL, + progress.bar = TRUE ) } \arguments{ \item{morts}{a dataframe with previously flagged mortalities. Format does -not need to match \code{new.data}, but the names and formats of \code{ID}, \code{station}, +not need to match \code{new.data} exactly, but the names and formats of \code{ID}, \code{station}, and \code{res.start} fields must match in all input dataframes.} \item{new.data}{a dataframe of new residence events (i.e., generated from @@ -67,6 +68,9 @@ be identical to the station/location names in \code{morts} and \code{new.data}.} \item{to.station}{a string of the name of the column in \code{ddd} that contains the station/location names where drifting detections may move to. Must be identical to the station/location names in \code{morts} and \code{new.data}.} + +\item{progress.bar}{option to display progress bar as function and called +functions are run. Default is TRUE.} } \value{ A dataframe with one row for each tag ID from \code{morts} @@ -84,8 +88,8 @@ alive. } \examples{ morts<-morts(data=events,type="mort",ID="ID",station="Station.Name", -method="any") +method="any",progress.bar=FALSE) undead<-review(morts=morts,new.data=new.data, -type="mort",ID="ID",station="Station.Name") +type="mort",ID="ID",station="Station.Name",progress.bar=FALSE) } diff --git a/man/season.Rd b/man/season.Rd index 8f802e8..25ad777 100644 --- a/man/season.Rd +++ b/man/season.Rd @@ -16,7 +16,7 @@ season( season.start, season.end, overlap = TRUE, - progressbar = TRUE + progress.bar = TRUE ) } \arguments{ @@ -64,7 +64,7 @@ residence events that is within the period of interest will be retained, and \code{residences} will be recalculated, using specified \code{units}. Default is \code{TRUE}.} -\item{progressbar}{option to display progress bar as function is run. Default +\item{progress.bar}{option to display progress bar as function is run. Default is TRUE.} } \value{ @@ -82,11 +82,14 @@ potential mortalities to be missed. \examples{ # Seasons in format dd-mm season.events<-season(data=events,type="mort",ID="ID", -station="Station.Name",season.start="01-06",season.end="31-10") +station="Station.Name",season.start="01-06",season.end="31-10", +progress.bar=FALSE) +head(season.events) # Seasons in format YYYY-mm-dd HH:MM:SS season.start<-c("2003-06-15","2004-06-21") season.end<-c("2003-10-15","2004-10-30") season.events<-season(data=events,type="mort",ID="ID", -station="Station.Name",season.start=season.start,season.end=season.end) +station="Station.Name",season.start=season.start,season.end=season.end,progress.bar=FALSE) +head(season.events) } diff --git a/man/stationchange.Rd b/man/stationchange.Rd index 1b86dc9..19e29ff 100644 --- a/man/stationchange.Rd +++ b/man/stationchange.Rd @@ -18,7 +18,7 @@ stationchange( units = NULL, from.station = NULL, to.station = NULL, - progressbar = TRUE + progress.bar = TRUE ) } \arguments{ @@ -66,7 +66,7 @@ be identical to the station/location names in \code{data}.} the station/location names where drifting detections may move to. Must be identical to the station/location names in \code{data}.} -\item{progressbar}{option to display progress bar as function is run. Default +\item{progress.bar}{option to display progress bar as function is run. Default is TRUE.} } \value{ @@ -81,5 +81,6 @@ Identify the most recent station or location change from passive acoustic telemetry data. } \examples{ -stn.change<-stationchange(data=events,type="mort",ID="ID",station="Station.Name") +stn.change<-stationchange(data=events,type="mort",ID="ID",station="Station.Name",progress.bar=FALSE) +head(stn.change) } diff --git a/vignettes/a2_morts.Rmd b/vignettes/a2_morts.Rmd index 77f79b2..f4aec58 100644 --- a/vignettes/a2_morts.Rmd +++ b/vignettes/a2_morts.Rmd @@ -32,11 +32,11 @@ All options rely on identifying the most recent station or location change for e The black points in the plot below show examples of the most recent station changes. See `stationchange()` and the [Digging](https://rosieluain.github.io/mort/articles/a6_digging.html) vignette for more information on how mort identifies station changes. ```{r stnchange_plot,echo=FALSE,fig.width=7} -stn.change<-stationchange(data=events[events$ID %in% c("G","K"),],type="mort",ID="ID",station="Station.Name",progressbar=FALSE) +stn.change<-stationchange(data=events[events$ID %in% c("G","K"),],type="mort",ID="ID",station="Station.Name",progress.bar=FALSE) plot<-mortsplot(data=events[events$ID %in% c("G","K"),], type="mort",ID="ID",station="Station.Name", season.start="2004-06-22",season.end="2004-07-01", - progressbar=FALSE) + progress.bar=FALSE) plot<-plot+ geom_point(data=stn.change,aes(x=ResidenceStart,y=ID))+ scale_colour_discrete(name="Station Name")+ @@ -52,10 +52,10 @@ These long residences can be explored by the user using the `resmax()` function ```{r resmax_ex,echo=FALSE} stn.change<-stationchange(data=events,type="mort",ID="ID",station="Station.Name", - progressbar=FALSE) + progress.bar=FALSE) rm_example<-resmax(data=events,ID="ID",station="Station.Name", res.start="ResidenceStart",residences="ResidenceLength.days", - stnchange=stn.change,progressbar=FALSE) + stnchange=stn.change,progress.bar=FALSE) rm_example<-rm_example[order(rm_example$ResidenceLength.days,decreasing=TRUE),] row.names(rm_example)<-NULL knitr::kable(head(rm_example),align="c") @@ -126,7 +126,7 @@ cml_res<-data.frame(ID=c("C","L"), plot<-mortsplot(data=events[events$ID %in% c("C","L"),], type="mort",ID="ID",station="Station.Name", season.start="2004-03-26",season.end="2004-06-23", - progressbar=FALSE) + progress.bar=FALSE) plot<-plot+ geom_point(data=cml_res,aes(x=Start,y=ID))+ geom_point(data=cml_res,aes(x=End,y=ID))+ @@ -139,13 +139,13 @@ The threshold for cumulative residence events is identified similarly to that fo ```{r resmaxcml_ex,echo=FALSE} stn.change<-stationchange(data=events,type="mort",ID="ID",station="Station.Name", - progressbar=FALSE) + progress.bar=FALSE) rmc_example<-resmaxcml(data=events,ID="ID",station="Station.Name", res.start="ResidenceStart", res.end="ResidenceEnd", residences="ResidenceLength.days", units="days", - stnchange=stn.change,progressbar=FALSE) + stnchange=stn.change,progress.bar=FALSE) rmc_example<-rmc_example[order(rmc_example$ResidenceLength.days, decreasing=TRUE),] row.names(rmc_example)<-NULL @@ -202,7 +202,7 @@ The `infrequent()` function is used to identify potential mortalities or expelle plot<-mortsplot(data=events[events$ID %in% c("M","I"),], type="mort",ID="ID",station="Station.Name", season.start="2005-09-25",season.end="2006-09-25", - progressbar=FALSE) + progress.bar=FALSE) plot<-plot+ theme(legend.position="none") plot