Skip to content
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

Stripping heading at same level even when a higher level heading occurs between #19

Open
joethorley opened this issue May 5, 2023 · 5 comments

Comments

@joethorley
Copy link
Member

Heading 1 A

Heading X

Heading A

Heading X <- THIS IS BEING DROPPED ERRONEOUSLY

@sebdalgarno
Copy link
Member

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"                
> 

@sebdalgarno
Copy link
Member

is the new_only step necessary? @joethorley do you remember the cases that it is trying to address?

@sebdalgarno
Copy link
Member

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"
> 

@joethorley
Copy link
Member Author

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.

@joethorley
Copy link
Member Author

So yes we want new_only but it needs to be more nuanced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants