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
Not sure if this is a bug or intended behavior. The JSON in the second row of the input datatable is empty. If I expand the JSON with by = F and na.rm = T, the initial_rowno variable for rows 3 and 4 of the output is 2, when it should be 3. If I set na.rm = F, it becomes 3.
Obviously this issue can be avoided entirely by setting na.rm = F. Maybe it should be obvious to me why this behavior occurs, but it confused me so I thought I'd bring it up.
Thanks for all your work on this package, by the way!
patterns <- data.table::data.table(state_fips = c(1,2,3),
cat_origin = c('{"a": "2", "b": "3"}',
'{}',
'{"a": "4", "b": "5"}'))
> patterns
state_fips cat_origin
1: 1 {"a": "2", "b": "3"}
2: 2 {}
3: 3 {"a": "4", "b": "5"}
>
expand_cat_json(
patterns,
'cat_origin',
'index',
by = F,
na.rm = T
)
initial_rowno cat_origin index
1: 1 2 a
2: 1 3 b
3: 2 4 a
4: 2 5 b
expand_cat_json(
patterns,
'cat_origin',
'index',
by = F,
na.rm = F
)
initial_rowno cat_origin index
1: 1 2 a
2: 1 3 b
3: 3 4 a
4: 3 5 b
The text was updated successfully, but these errors were encountered:
berg-michael
changed the title
initial_rowno in expand_cat_json() is wrong if by=F, JSON empty, and na.rm = F
initial_rowno in expand_cat_json() is wrong if by=F, JSON empty, and na.rm = T
Jul 14, 2021
Hi,
Not sure if this is a bug or intended behavior. The JSON in the second row of the input datatable is empty. If I expand the JSON with by = F and na.rm = T, the initial_rowno variable for rows 3 and 4 of the output is 2, when it should be 3. If I set na.rm = F, it becomes 3.
Obviously this issue can be avoided entirely by setting na.rm = F. Maybe it should be obvious to me why this behavior occurs, but it confused me so I thought I'd bring it up.
Thanks for all your work on this package, by the way!
The text was updated successfully, but these errors were encountered: