From 3ca01c034a8f6b0c89c72902e47720f69686c3e6 Mon Sep 17 00:00:00 2001 From: JennaVergeynst Date: Mon, 29 Apr 2019 09:30:32 +0200 Subject: [PATCH] Update simTrack.R Proposal to add the parameter start_pos, enabling the user to specify the starting position of the simulated track. --- R/simTrack.R | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/R/simTrack.R b/R/simTrack.R index f543bd4..f876789 100644 --- a/R/simTrack.R +++ b/R/simTrack.R @@ -9,10 +9,11 @@ #' @param shape Shape of the Weibull distribution - only used when model='crw'. #' @param scale Scale of the Weibull distribution - only used when model='crw'. #' @param addDielPattern Adds a realistic(?) diel pattern to movement. Periods of both low and high movement +#' @param start_pos Specify the starting position of the track with c(x0, y0) #' #' @return Dataframe containing a simulated track - gnu #' @export -simTrueTrack <- function(model='rw', n, deltaTime=1, D=NULL, shape=NULL, scale=NULL, addDielPattern=TRUE){ +simTrueTrack <- function(model='rw', n, deltaTime=1, D=NULL, shape=NULL, scale=NULL, addDielPattern=TRUE, start_pos=NULL){ try(if(model=='rw' & is.null(D)) stop("When model == 'rw', D needs to be specified")) try(if(model=='crw' & (is.null(shape) | is.null(scale))) stop("When model == 'crw', shape and scale needs to be specified")) @@ -21,8 +22,13 @@ simTrueTrack <- function(model='rw', n, deltaTime=1, D=NULL, shape=NULL, scale=N time <- cumsum(c(0, dt)) #start position - x0 <- stats::runif(1,0,5) - y0 <- stats::runif(1,0,5) + if(!is.null(start_pos)){ + x0 <- start_pos[1] + y0 <- start_pos[2] + } else{ + x0 <- stats::runif(1,0,5) + y0 <- stats::runif(1,0,5) + } #RW-model if(model == 'rw'){