nikki
nikki

Reputation: 239

Row label using expss package

Is it possible to repeat labels on each row such that the output of below code should look alike:enter image description here

instead of: enter image description here

wherein the desired output should contain the labels on each row instead of first row only.

library("expss")
data(mtcars)
mtcars = apply_labels(mtcars,
                      mpg = "Miles/(US) gallon",
                      cyl = "Number of cylinders",
                      disp = "Displacement (cu.in.)",
                      hp = "Gross horsepower",
                      drat = "Rear axle ratio",
                      wt = "Weight (lb/1000)",
                      qsec = "1/4 mile time",
                      vs = "Engine",
                      vs = c("V-engine" = 0,
                             "Straight engine" = 1),
                      am = "Transmission",
                      am = c("Automatic" = 0,
                             "Manual"=1),
                      gear = "Number of forward gears",
                      carb = "Number of carburetors"
)
 mtcars %>% 
     tab_cells(cyl, gear) %>% 
     tab_prepend_all %>% 
     tab_cols(total(), vs) %>% 
     tab_stat_cpct() %>% 
     tab_pivot()

Upvotes: 0

Views: 235

Answers (1)

Gregory Demin
Gregory Demin

Reputation: 4836

If you are using as.datatable_widget function for output then there is a special argument repeat_row_labels. Set it to TRUE to get desired result. If you are using split_columns there is an other argument which is inconsistently named as remove_repeated. Set it to FALSE to repeat row labels.

Upvotes: 0

Related Questions