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

Add tidy_near_repeat() function and tests #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mpjashby
Copy link

The NearRepeat() function is really useful, but it's hard to use within a pipeline (e.g. using %>% or the new base-R |>) of functions because the inputs must be provided as separate vectors and the output is a nested list of matrices.

I've added a new wrapper around NearRepeat() called tidy_near_repeat() that accepts the input in the form of a data frame or tibble along with the names of the columns containing the x, y and time values.

This function also:

  • Identifies the time column in the data automatically if no column is specified and the data contains exactly one Date-type column.
  • Extracts the x and y co-ordinates automatically if the data is an SF object and no x and y columns are specified.
  • If the co-ordinates are given as longitudes and latitudes, warns users that the values of sds will be interpreted as being in decimal degress.
  • Provides default values for the sds and tds arguments.
  • Formats the output from NearRepeat() into a tibble that follows the conventions for tidy data.
  • Warns users if near repeats are significant for the largest distance or time bands.
  • Produces an explanatory message if zero counts mean some Knox ratios could not be calculated.

I've also added tests that cover the inputs and outputs of the functions.

Previously, tidy_near_repeat() would only work if the column of dates had the type Date, whereas dates can also be stored in columns with type POSIXt. Now either will work.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant