Open joethorley opened 1 year ago
narrowed it down to internal set_headings
function and more specifically
> str(heading)
chr [1:2, 1:2] "Count" "Count2" "Species" "Species"
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:2] "sub1" "sub2"
>
being passed to
heading <- apply(heading, MARGIN = 2, new_only)
with new_only, the second column of heading gets converted to c("Species", NA) since they are duplicated
> heading
sub1 sub2
[1,] "Count" "Species"
[2,] "Count2" "Species"
to
> heading
sub1 sub2
[1,] "Count" "Species"
[2,] "Count2" NA
NA is dropped when collapsed and this becomes
heading
[1] "\n#### Count\n\n##### Species\n" "\n#### Count2\n"
>
is the new_only step necessary? @joethorley do you remember the cases that it is trying to address?
or do we want to work on the rows instead? i.e.
heading <- apply(heading, MARGIN = 1, subreport:::new_only)
gives
> heading
[1] "\n#### Count\n\n#### Species\n" "\n##### Count2\n\n##### Species\n"
>
It's a good question. We only want to drop a subheading if it and all its higher level headings are the same. Currently it just ask is it the same at the same level.
So yes we want new_only but it needs to be more nuanced.
Heading 1 A
Heading X
Heading A
Heading X <- THIS IS BEING DROPPED ERRONEOUSLY