Hi all.. I am doing an survival analysis, and the code works fine in RStudio, but when copying it into Quarto, I get the following error message:
"Quitting from lines 480-491 [quartiles] (report.qmd)
Error in cut.default()
:
! 'x' must be numeric
Backtrace:
- base::cut(...)
- base::cut.default(...)
Execution halted
The code is as follows:
data$quartiles <- cut(data$mean_treatment_time_hours,
breaks = quantile(data$mean_treatment_time_hours,
probs = c(0, 1/4, 2/4, 3/4, 1), na.rm = TRUE),
labels = c("Quartile 1", "Quartile 2", "Quartile 3", "Quartile 4"),
include.lowest = TRUE)
quartilenames <- c("Quartile 1", "Quartile 2", "Quartile 3", "Quartile 4")
data$quartiles.fac <- factor(x = data$quartiles, levels = quartilenames, ordered = TRUE)
When I check class(data$mean_treatment_time_hours)
- the console returns numeric....
Any ideas? Thanks in advance, Jim