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

Issue #133 file locations for distances matrix() #145

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

Conversation

dsmith-unbc
Copy link
Contributor

Updated distanceMatrix() to accept a new condition 'file_path'. This will solve issue [#133] where if the 'spatial.csv' is not in the main working directory the function will error. New checks have also been added for 'file_path in' distanceMatrix() plus the documentation for distanceMatrix() has been updated to reflect 'file_path' being added.

@dsmith-unbc
Copy link
Contributor Author

Notes based on discussion with Hugo:

If distancesMatrix() is called without starters, have function look for spatial.csv in current working directory (this is the current functionality).

Utilize the loadSpatial() function being called before distancesMatrix() for other processes. This would have the existing path of spatial.csv already denoted in it. Use the output of loadSpatial() as a input for distancesMatrix() which would be put in the starters argument. This would bypass the need for an additional argument while still providing the information needed to run distancesMatrix().

Starters and targets in distancesMatrix() define endpoints used to calculate distances. Normally, these two are the same values (as we want to calculate the distances between every pair of points).

Currently, if actel = TRUE, distancesMatrix() will ignore the starters argument. However, distancesMatrix() should inherently always try to optimize the output for actel.

Summary: Relax the distancesMatrix() function so it accepts starters regardless of actel being TRUE or not. Allow the user to supply the output of loadSpatial() to starters so the spatial.csv can be accessed. Keep the default functionality of distanceMatrix() the same where if no starters are provided, distancesMatrix() looks for a spatial.csv in the current working directory.

@hugomflavio Please give this a read through and provide feedback if something requires rectifying.

@hugomflavio
Copy link
Owner

Looks good. One comment:

Currently, if actel = TRUE, distancesMatrix() will ignore the starters argument. However, distancesMatrix() should inherently always try to optimize the output for actel.

I'd rephrase this thought to: However, distancesMatrix() should try to optimize the output for actel if actel = TRUE even if starters/targets arguments have been provided by the user.

Had a quick look at distancesMatrix() to see if anything else could go wrong. It seems it already has fail-safes for if id.col does not exist. It still makes sense for force id.col to be "Standard.name" when actel = TRUE, as that is what actel will look for. I suppose distancesMatrix() should crash if 1) actel = TRUE and 2) starters/targets were supplied but do not contain a column called "Standard.name".

dsmith-unbc and others added 5 commits November 19, 2024 09:15
…f 'loadSpatial()' can now be used in place of starters when actel == TRUE
…moved old checks related to file_path and removed checks which checked for errors or warning no longer present.
…o be specified when actel == TRUE. This also allows 'loadSpatial()' to be used in starters to specify if the 'spatial.csv' is in a different working directory. Also updated code to allow 'distances.csv' to be saved to a specific folder if the user desires.
@dsmith-unbc
Copy link
Contributor Author

First push to address issue from a loadSpatial() approach. Function will now accept loadSpatial() output for starters and if no starters or targets are specified, then function searches and grabs 'spatial.csv' from working directory as done previously.

The function will now allow starters and targets to be specified when actel == TRUE.

If starters are applied and targets are left blank, starters will be used as targets.

Added new code to the end allowing the user to specify the folder where the 'distances.csv' should be saved to. Or the user can have it left default and the 'distances.csv' will be saved to the working directory.

Relevant documentation has been updated as well as news.

The distancesMatrix() examples in the help documentation did seem confusing we should considering altering that to be more intuitive of how the function works right now.

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.

2 participants