I have created an ordered factor within a dataframe, as shown below:
med_ttest_tbl2$injury_prepost <- factor(med_ttest_tbl2$injury_prepost, levels=desired_order)
Wheredesired_order <- c("Pre","Post")
The intent was to switch the order of "Pre" and "Post" in this column. When I run levels()
to confirm the ordering, it appears to run properly:
levels(med_ttest_tbl2$injury_prepost)
Gives the output:[1] "Pre" "Post"
I then included this table in my RMD file, which I'm using to create an HTML output, using the following code in RMD:
kable(med_ttest_tbl2, "html") %>% kable_styling("striped", full_width = F)
The order is then switched back to what it was before that ordered factor was introduced. Is this an issue with table()? kable()? Something else? Here's the final output:
Thanks in advance!