Visualize error code when reopened file
Opened this issue · 0 comments
Hi
I made lovely plots from a YouTube tutorial (new to R) and when I reopened my file, the script returned an error.
Can you help please, I have been googling for hours?
require(ggplot2)
require(mediation)
library(flexplot)
data= (Data_analysis_moderation)
names(Data_analysis_moderation)
#step two: predict the mediator with the variable of interest
mediate_model = lm(CIT_TEAQGestation_, data=Data_analysis_moderation)CIT_TEAQ + Gestation_, data = Data_analysis_moderation)
summary(mediate_model)
require(flexplot)
visualize(mediate_model)
#step 3:fit the whole model
full_model = lm(PHQ_Score
summary(full_model)
results = mediate(mediate_model, full_model, treat = 'Gestation_', mediator = "CIT_TEAQ",boot = TRUE, sims=500)
summary(results)
error:
! Can't convert x
<haven_labelled> to .
Backtrace:
▆
- ├─flexplot::visualize(mediate_model)
- └─flexplot:::visualize.lm(mediate_model)
- └─flexplot::compare.fits(f, data = data, model1 = object, ...)
-
└─flexplot::flexplot(...)
-
└─flexplot:::flexplot_modify_data(...)
-
└─flexplot:::flexplot_convert_to_categorical(data, axis)
-
└─base::factor(data[, axis[1]], ordered = T)
-
├─base::unique(as.character(y)[ind])
-
├─base::as.character(y)
-
└─vctrs:::as.character.vctrs_vctr(y)
Run rlang::last_trace(drop = FALSE) to see 11 hidden frames.