-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
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!
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
Metadata
Metadata
Assignees
Labels
No labels