relevel characteristics

Hi guys,

I have the following question:
image

As you can see, the characteristic "post" is on the first place when i create a table. But i would like to have it other way around: so that first the "pre" comes and then next to it the "post".
I tried to do it with the relevel function and set "pre" as the reference. But it didn't work.

Can you please help me how to do such an easy thing?

Thank you very much.

Please see FAQ: What's a reproducible example (`reprex`) and how do I do one? Using a reprex, complete with representative data will attract quicker and more answers.

This is simple enough not to strictly require one, but screenshots make it a nuisance to duplicate the object. So, I'll use a subset of the built-in dataset mtcars

suppressPackageStartupMessages(library(dplyr)) 

my_data <- mtcars[1:2]
head(my_data)
#>                    mpg cyl
#> Mazda RX4         21.0   6
#> Mazda RX4 Wag     21.0   6
#> Datsun 710        22.8   4
#> Hornet 4 Drive    21.4   6
#> Hornet Sportabout 18.7   8
#> Valiant           18.1   6
my_data <- my_data[2:1]
head(my_data)
#>                   cyl  mpg
#> Mazda RX4           6 21.0
#> Mazda RX4 Wag       6 21.0
#> Datsun 710          4 22.8
#> Hornet 4 Drive      6 21.4
#> Hornet Sportabout   8 18.7
#> Valiant             6 18.1

# more intuitive way (swaps back to original)

my_data %>% select(mpg,cyl) -> my_data

head(my_data)
#>                    mpg cyl
#> Mazda RX4         21.0   6
#> Mazda RX4 Wag     21.0   6
#> Datsun 710        22.8   4
#> Hornet 4 Drive    21.4   6
#> Hornet Sportabout 18.7   8
#> Valiant           18.1   6

Created on 2020-03-27 by the reprex package (v0.3.0)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.