gdemin / expss

expss: Tables and Labels in R
https://cran.r-project.org/web/packages/expss/
84 stars 16 forks source link

sorted columns #78

Closed zelihay closed 3 years ago

zelihay commented 3 years ago

Hi Mr. Demin,

I hope you are safe and sound.

I have a little bit complicated issue; I hope you can help me.

I am trying to use _tab_sortdesc function. But I need to tell the program where to stop for rows. Also, I want to pick up columns that I need to sort the table sequentially. I have 5 columns, and I need to sort the table 5 times. It is a weekly project, so I'll add a new week's column every week, and I need to sort the table by the last week's columns.

I have repeated texts between rows, and I want to sort these rows by checking that text. So, I need to use _excludedrows argument. But I could not manage to apply it. I think the reason for that is nested row variables. The table starts at column number 5 (Column E).

To sum up, I want to say that sort the rows until you see "Index1" by column number 7, then sort it by column number 10, then 13, then 16, then 19. You can find the table in the attachment. demo.xlsx

I hope I've explained it clearly. I really appreciate any help you can provide.

Best, Zeliha

zelihay commented 3 years ago

here is the script;

A %>% tab_prepend_all %>% tab_cols(Q1 %nest% Week) %>% tab_cells(Persona %nest% Index1) %>% tab_stat_cpct(total_row_position = "none") %>% tab_pivot()

gdemin commented 3 years ago

You can address columns by there number:

tab_sort_desc(7, 10, 13, 16, 19, excluded_rows = "#|(Index1 Ürünler$)")

$ in the excluded rows means end of line - so we exclude only rows without text after index. If you want more detailed code, please, drop here result of the dput on your unsorted table.

zelihay commented 3 years ago

Thanks, Mr. Denim. It's worked.