-
Notifications
You must be signed in to change notification settings - Fork 20
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
Optionally apply merged cells across their range #40
Comments
On this topic, I was wondering what the default behavior was with tidyxl when it encounters merged cells.
If so, I think the enhead function in https://github.com/nacnudus/unpivotr will handle this problem fairly easily. |
That's correct, and is the reason why I haven't thought of a need for this yet. It might still be useful to know when a cell is part of a merge. |
@ianmoran11 thanks for commenting here. I've skimmed ianmoran11/tidyABS@d34fd3f to try to understand the use of unmerging cells, but I don't understand yet. Is it part of guessing which cells are headers? If so, would it be enough to know that a cell is merged? That would be much easier to implement than the next step, which is to clone that cell across the merged range. |
Sorry, I missed your reply. Unmerging column headers, in ABS tables, increases the chance that N gives the correct relationship between the table data and the header (and this seems to be true of many other tables too). Without unmerging the column header, tidyABS would need to guess between NNW or N for each column header group, which turns out to be difficult. Knowing whether the cell is merged would allow me to know with more certainty whether I should replace a cell's value with the value of the cell to the left. I'm hope that explanation is clear - happy to provide a reprex to clarify. |
I see. Could tidyABS use NNW every time? N is a convenient way to filter out cells that are outside the table (they don't have any headers), but otherwise it makes no difference. If tidyABS has another way to drop cells outside the table, then I would recommend this approach because it generalises to header cells that haven't been merged. |
Using NNW every time was my initial approach, but it runs into trouble with some tables. See, for example, the table below. By the way, I don't have a good understanding of how much work would be involved in adding this feature, and tidyABS gets by most of the time with its current approach to unmerging and filling cells, so this is far from an urgent request - just a nice-to-have. |
Excellent example. I'm persuaded. I had a go at this last night and it's just fiddly, not actually difficult. |
Alternatively, two additional columns can be added
The |
Just wanted to say that this would be helpful for my usage too. @rpsoft I am using tidyxl to re-arrange tables from published papers into a tidy format.
However, I wonder if merged_cell_id should not be NA, but rather should be the address for the top left cell, and in the case of single cells, this is of course just the cell reference.
|
Thanks @bedantaguru and @dmcalli2 for the suggestions. What do you think about:
|
Sounds great. Do you think that it would be good to set the value of
|
Oh yes, I meant to ask what value you would expect merged cells to have (other than the top-left). I had assumed they ought to be pre-populated with the value of the top-left cell, in which case your example wouldn't be necessary. |
I think you are right. |
@nacnudus agree to not have I guess as you suggested In fact, your initial suggestion is also perfect (to optionally populate same fields for all cells in the merge). But in this case, you need an optional argument in If the operation is not costly then you may choose the first one otherwise go for the second. Either way, it looks perfectly fine. |
I can see the xlsx contains information like these : |
Is the desired behaviour agreed now (see below) and if so can we (myself and @rpsoft) help with the implementation, as this feature would be very useful for our current project? Desired behaviour
|
@bedantaguru you are right, @dmcalli2 and @rpsoft thank you for offering to help with the implementation, which will be as follows (suggestions still accepted though!):
I haven't checked whether the formatting of a merged cell is the same as the top-left cell in the merge. Hopefully it is, otherwise unmerging will be a Grade A pain. Sorry for being slow to develop this. I don't have much time to spend on tidyxl at the moment. |
Great. I'll fork the repo, talk with @rpsoft and make a plan. |
How are you all guys.. Have you given it a try... |
Hi, also desperately needing this feature... |
E.g. if a cell with value "foo" is merged across
A1:A2
then cellA2
should be created/overridden as a clone.The text was updated successfully, but these errors were encountered: