Returns a matrix of travel direction between all observations of one unique fish.

riverdirectionmatbysurvey(indiv, unique, survey, seg, vert, rivers,
  full = TRUE, flowconnected = FALSE, stopiferror = TRUE,
  algorithm = NULL)

Arguments

indiv

The unique identifier of the fish in question.

unique

A vector of identifiers for each fish.

survey

A vector of identifiers for each survey. It is recommended to use a numeric or date format (see as.Date) to preserve survey order.

seg

A vector of river locations (segment component).

vert

A vector of river locations (vertex component).

rivers

The river network object to use.

full

Whether to return the full matrix, with NA values for missing data (TRUE), or a the subset of rows and columns corresponding to successful observations. Defaults to TRUE.

flowconnected

If TRUE, only returns direction if the input segments are flow-connected. Defaults to FALSE.

stopiferror

Whether or not to exit with an error if a route cannot be found. If this is set to FALSE and a route cannot be found, the function will return NA in the appropriate entry. Defaults to TRUE. See detectroute.

algorithm

Which route detection algorithm to use ("Dijkstra", "sequential", or "segroutes"). If left as NULL (the default), the function will automatically make a selection. See detectroute for more details.

Value

A matrix of directions (character), with rows and columns defined by survey. In the resulting matrix, the element with the row identified as A and column identified as B is defined as the direction traveled from survey A to survey B. Therefore, it is likely that only the upper triangle of the matrix will be of interest.

Note

Building routes from the river mouth to each river network segment and/or distance lookup tables will greatly reduce computation time (see buildsegroutes).

See also

riverdirection

Examples

data(Gulk, fakefish) riverdirectionmatbysurvey(indiv=1, unique=fakefish$fish.id, survey=fakefish$flight, seg=fakefish$seg, vert=fakefish$vert, rivers=Gulk)
#> 1 2 3 4 5 6 7 8 9 10 #> 1 "0" "up" NA "up" "up" NA NA "up" "up" "up" #> 2 "down" "0" NA "up" "up" NA NA "down" "down" "down" #> 3 NA NA NA NA NA NA NA NA NA NA #> 4 "down" "down" NA "0" "up" NA NA "down" "down" "down" #> 5 "down" "down" NA "down" "0" NA NA "down" "down" "down" #> 6 NA NA NA NA NA NA NA NA NA NA #> 7 NA NA NA NA NA NA NA NA NA NA #> 8 "down" "up" NA "up" "up" NA NA "0" "down" "down" #> 9 "down" "up" NA "up" "up" NA NA "up" "0" "down" #> 10 "down" "up" NA "up" "up" NA NA "up" "up" "0"
riverdirectionmatbysurvey(indiv=1, unique=fakefish$fish.id, survey=fakefish$flight, seg=fakefish$seg, vert=fakefish$vert, rivers=Gulk, full=FALSE)
#> 1 2 4 5 8 9 10 #> 1 "0" "up" "up" "up" "up" "up" "up" #> 2 "down" "0" "up" "up" "down" "down" "down" #> 4 "down" "down" "0" "up" "down" "down" "down" #> 5 "down" "down" "down" "0" "down" "down" "down" #> 8 "down" "up" "up" "up" "0" "down" "down" #> 9 "down" "up" "up" "up" "up" "0" "down" #> 10 "down" "up" "up" "up" "up" "up" "0"