Why this output:

The output means that your predictor LN12
is an "ordered factor".
R knows that the elements in your category are not only distinct, but also
have a natural order.
The .L
(=linear) and .Q
(=quadratic) comes from the intention of R to fit a series of polynomial functions or contrasts of your variable LN12
. From fantastic answer.
Here is an example how you can tweak and play around:
Example data from here
data:
dataSOF <-
structure(
list(
ID = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
age = c(62, 57, 67, 74, 71, 67, 46, 71, 53, 63),
disease = c(0, 1, 1, 1, 1, 0, 1, 0, 0, 0),
death = c(0, 0, 1, 0, 1, 1, 0, 1, 0, 1),
censored_survival_days = c(60, 60, 60, 60, 60, 60, 60, 60, 60, 60),
censored_survival_status = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
),
row.names = c(NA, -10L),
class = c("tbl_df", "tbl", "data.frame")
)
ORDERED FACTOR
ord_dataSOF <- dataSOF %>%
mutate(age50 = cut(age, breaks=c(0,50,100), include.lowest=TRUE,
labels=c("< 50 years", ">= 50 years"), ordered = TRUE))
tbl_uvregression(
ord_dataSOF,
method=coxph,
y = Surv(time = censored_survival_days, event = censored_survival_status),
exponentiate = TRUE,
include = -ID)
)

FACTOR
factor_dataSOF <- dataSOF %>%
mutate(age50 = ifelse(age <50, "age<50", "age>=50"),
age50 = factor(age50))
tbl_uvregression(
factor_dataSOF,
method=coxph,
y = Surv(time = censored_survival_days, event = censored_survival_status),
exponentiate = TRUE,
include = -ID)
)

@Daniel D. Sjoberg Why does this not work using modify_table_body
from (here)[https://stackoverflow.com/questions/70887776/rename-levels-of-a-factor-in-tbl-regression]
library(gtsummary)
library(survival)
dataSOF %>%
mutate(age50 = cut(age, breaks=c(0,50,100), include.lowest=TRUE,
labels=c("< 50 years", ">= 50 years"), ordered = TRUE)) %>%
tbl_uvregression(
method=coxph,
y = Surv(time = censored_survival_days, event = censored_survival_status),
exponentiate = TRUE,
include = -ID,
label = list(
age50 ~ "50 years")
) %>%
modify_table_body(
~.x %>%
mutate(age50 = ifelse(age50 == "0", "<50 year",
ifelse(age50 =="1", ">= 50 years",age50)))
)
#error:
Error in `mutate()`:
! Problem while computing `age50 = ifelse(...)`.
Caused by error in `ifelse()`:
! object 'age50' not found