hugomflavio / actel

Standardised analysis of acoustic telemetry data from fish moving through receiver arrays
https://hugomflavio.github.io/actel-website
26 stars 6 forks source link

Add documentation for example code for distancesMatrix where user already has t.layer and spatial objects loaded in environment #129

Open SimonDedman opened 1 month ago

SimonDedman commented 1 month ago

Would be nice for users to have a guide for how to do this, given I expect a standard workflow will be to create objects in order, following the manual. And therefore to have all objects in the environment. Example:

distances <- actel::distancesMatrix(
  t.layer = t.layer,
  starters = spatial,
  targets = spatial,
  coord.x = "Longitude",
  coord.y = "Latitude",
  id.col = NULL,
  actel = FALSE
)
SimonDedman commented 1 month ago

Regarding this: would be especially good to have more info on id.col. Because I'm using a spatial object not csv, I have to use actel=FALSE, and thus specify everything else, which feels like a bit of a waste of the coding you've done in the backend.

Anyway, having done so, I've tried various things to solve a later warning that Colnames & rownames don't match due to Xs (colnames were 1 2 3 converted by R to X1 X2 X3 but then they don't match rownames which are 1 2 3):

id.col = Station.name,

Error: object 'Station.name' not found

id.col = spatial$Station.name,

Error: Please provide only one column name in 'id.col'

id.col = "Station.name",

Error in .rowNamesDF<-(x, value = value) : invalid 'row.names' length

spatial <- spatial |> dplyr::mutate(Station.name = stringr::str_replace_all(string = Station.name, pattern = " ", replacement = "_"))
id.col = "Station.name",

Error in .rowNamesDF<-(x, value = value) : invalid 'row.names' length

And finally, old faithful:

colnames(distances) <- spatial$Station.name
rownames(distances) <- spatial$Station.name