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

Tab stops are put in column 1 ignoring the selection (e.g. j=3:8) #635

Open
adrianolszewski opened this issue May 27, 2024 · 2 comments
Open

Comments

@adrianolszewski
Copy link

adrianolszewski commented May 27, 2024

Hello @davidgohel
First of all, thank you wholeheartedly for bringing decimal (and other) tabulation marks into flextable. It is totally a game changer!
And it works perfectly.

Only I noticed one thing. I formatted a table, where the 2 first columns described the content, and the remaining columns held the numeric content.

In the 1st column I prepended the content with "\t" to mimic a nested hierarchy of items. That's very common in my field.

I didn't need any specific positions of tab stops here. Just plain, simple tabs. So I explicitly told flextable to put tab stops only in concrete cells: at the cross of i=1:nrow(data) and j=3:8.

Yet the tab stops were put in the first column too, which spoiled the hierarchy.
obraz

Luckily it was enough to select the 1 column and delete the tab stops with a mouse to fix it.

obraz

Maybe this issue was caused by the fact that I merged cells in the the 1 row to make a vertical sub-header?

@adrianolszewski
Copy link
Author

Is it possible to set the tab stops for a selection of columns?

When I tried doing separate assignments, an error was returned:

   tab_settings(part="body",
+                i=1:nrow(result),
+                j=3:8,
+                fp_tabs(
+                  fp_tab(pos = 0.65/2.54, style="decimal")
+                )) +
+   
+   tab_settings(part="body",
+                i=1:nrow(result),
+                j=14,
+                fp_tabs(
+                  fp_tab(pos = 0.7/2.54, style="decimal"),
+                  fp_tab(pos = 1.23/2.54, style="left"),
+                  fp_tab(pos = 1.97/2.54, style="decimal")
+                ))

Error in nrow_part(x, part) :
Function `nrow_part()` supports only flextable objects.

And it seems that tab stops are set indeed for the entire table, it ignores the column selection.

@davidgohel
Copy link
Owner

Hello,

sorry, we can't reproduce the error. We would need a reproductible example!

In the code you shared, you are using +, is it not |> that you wanted to use ?

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

No branches or pull requests

2 participants