Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update simTrack.R #7

Merged
merged 2 commits into from
Nov 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions R/simTrack.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
#' @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)
#' @param ss Simulations model for Speed of Sound - defaults to 'rw' = RW-model.
#'
#' @return Dataframe containing a simulated track
#' @export
simTrueTrack <- function(model='rw', n, deltaTime=1, D=NULL, shape=NULL, scale=NULL, addDielPattern=TRUE, ss='rw'){
simTrueTrack <- function(model='rw', n, deltaTime=1, D=NULL, shape=NULL, scale=NULL, addDielPattern=TRUE, ss='rw', 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"))

Expand All @@ -22,8 +23,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'){
Expand Down