-
Notifications
You must be signed in to change notification settings - Fork 56
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
Making network_plot more robust #107
Conversation
Merge pull request #105 from thisisdaryn/master
Updating with main repo
resyncing with tidymodels/corrr
This looks really good, but I think we probably should give a more user-friendly warning about what is happening and why. Can you check out the tidyverse style guide on error messages and add a different warning for these shifts? We should probably use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Warning messages modified.
> camas_desempleo %>%
+ select(-CCAA) %>%
+ correlate() %>%
+ network_plot()
Correlation method: 'pearson'
Missing treated using: 'pairwise.complete.obs'
Warning messages:
1: Matrix of coordinates has dimension < 2
2: Matrix of coordinates has dimension < 2
3: Matrix of coordinates has dimension < 2
4: Matrix of coordinates has dimension < 2
5: Matrix of coordinates has dimension < 2
6: Matrix of coordinates has dimension < 2
This is looking great! Let's do just one more little round of edits on the warning message itself. I suspect a typical user may think, "Wait, what has gone wrong?! I didn't give this function any matrix of coordinates???" 🤔 What do you think could be a good option for a slightly revamped message?
Other ideas? |
Idea: to tweak the latter option
This is a tricky question because the quantity being changed was an approximation anyway. I don't think it is correct to say either that the correlations have been shifted or that correlate() output has been adjusted. The correlations are being represented in the plot in 2 ways:
What we are really trying to convey is that the distances between the nodes have knowingly been increased in this instance. |
I think that is fantastic. 👍 Let's go with that option. |
Question: how important is it that we pass along/translate warnings from the base R function call internal to the function? The latest iteration of the PR suppresses a warning from a base R function and paraphrases it in the hope of being more helpful to the user who didn't call that function. So the number of warnings that get to the end-user is still the same as the total number of warnings i.e. one for each time a shift is applied (6 in this case). Is it an option to provide a single warning to indicate that one or more attempts were made to find a shift distance that works? I think this may be possible to articulate without detracting from the user's ability to locate the error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Warning messages changed.
Excellent! 🙌 I see what you're saying about the repetition of the messages. My feeling is that it is not that helpful for the user to see the same warning a bunch of times in this situation. What do you think about only showing the user the warning once, when one or more shifts has been changed? |
Relaying a single warning message to indicate that the distances have been distorted further for the purpose of placing the points in the network plot. Previous iteration of the code raised a warning each time a shift distance was tried.
Excellent! 🙌 Thank you so much for your work on this. |
macOS R devel GH action builds are all broken right now, FWIW. |
This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue. |
Addresses #106
If the call to
stats::cmdscale
internal tonetwork_plot
does not return a matrix of 2 columns, uniform shifts are added to the off-diagonal entries of the distance matrix and another attempt is made. The search for the shift value iterates through a fixed list of possible values, 10^(-6:-1), before terminating.The error in the #106 arises at the point of trying to rename the first 2 columns of a matrix that has only one column.
Warnings from
stats::cmdscale
are not suppressed but they could be. As is, the end-user of network plot will see warnings for each call that does not return a matrix of 2 columns.Test running with the data of #106 (The variables in the example data are highly-correlated):