You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've found an issue where assumptions made by check_zero() cause some graph plotting operations to fail silently if you have a 1-indexed rather than 0-indexed dataset for Links . I have a fix ready and will raise a PR for review in a sec.
To reproduce
It's a bit involved so bear with me. I initially found this when using sankeyNetwork() but it also affects forceNetwork().
First we pretend we have some 1-indexed link data:
sankeyNetwork(
Links=bad_energy$links,
Nodes=bad_energy$nodes,
Source='source',
Target='target',
Value='value'
)
#> Warning message:#> It looks like Source/Target is not zero-indexed. This is required in JavaScript and so your plot may not render.
However, if we pass in a tbl_df we get no warning and no plot. We do see a message about data frame conversion but nothing about the 1-indexing error, and no plot is rendered.
sankeyNetwork(
Links=tibble::as_tibble(bad_energy$links),
Nodes=bad_energy$nodes,
Source='source',
Target='target',
Value='value'
)
#> Links is a tbl_df. Converting to a plain data frame.
This is caused by the way Links is subset in the call to check_zero():
The problem arises when Links is a tbl_df because [.tbl_df returns a tbl_df even if only one column is selected, unlike [.data.frame. This breaks check_zero() because it assumes its inputs are vectors.
We can get the same effect by omitting Source or Target - when these are missing the subsetting operation returns the entire data frame, which again breaks check_zero().
# Both of these calls produce no plot and no warning
sankeyNetwork(
Links=bad_energy$links,
Nodes=bad_energy$nodes,
# Source = 'source',Target='target',
Value='value'
)
sankeyNetwork(
Links=bad_energy$links,
Nodes=bad_energy$nodes,
Source='source',
# Target = 'target',Value='value'
)
Fix
I've created a PR to fix this (basically just move check_zero() after input checking and tbl_df_strip()) which I will link in a sec.
Hope this is helpful, thanks again!
The text was updated successfully, but these errors were encountered:
Hi, thanks for an awesome package!
I've found an issue where assumptions made by
check_zero()
cause some graph plotting operations to fail silently if you have a 1-indexed rather than 0-indexed dataset forLinks
. I have a fix ready and will raise a PR for review in a sec.To reproduce
It's a bit involved so bear with me. I initially found this when using
sankeyNetwork()
but it also affectsforceNetwork()
.First we pretend we have some 1-indexed link data:
Normally we get a warning for this
However, if we pass in a
tbl_df
we get no warning and no plot. We do see a message about data frame conversion but nothing about the 1-indexing error, and no plot is rendered.This is caused by the way
Links
is subset in the call tocheck_zero()
:The problem arises when
Links
is atbl_df
because[.tbl_df
returns atbl_df
even if only one column is selected, unlike[.data.frame
. This breakscheck_zero()
because it assumes its inputs are vectors.We can get the same effect by omitting
Source
orTarget
- when these are missing the subsetting operation returns the entire data frame, which again breakscheck_zero()
.Fix
I've created a PR to fix this (basically just move
check_zero()
after input checking andtbl_df_strip()
) which I will link in a sec.Hope this is helpful, thanks again!
The text was updated successfully, but these errors were encountered: