Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visualize error code when reopened file #117

Open
Fronkers239 opened this issue Apr 28, 2023 · 0 comments
Open

Visualize error code when reopened file #117

Fronkers239 opened this issue Apr 28, 2023 · 0 comments

Comments

@Fronkers239
Copy link

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)
summary(mediate_model)
require(flexplot)
visualize(mediate_model)
#step 3:fit the whole model
full_model = lm(PHQ_Score
CIT_TEAQ + Gestation_, data = Data_analysis_moderation)
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:

  1. ├─flexplot::visualize(mediate_model)
  2. └─flexplot:::visualize.lm(mediate_model)
  3. └─flexplot::compare.fits(f, data = data, model1 = object, ...)
  4. └─flexplot::flexplot(...)
    
  5.   └─flexplot:::flexplot_modify_data(...)
    
  6.     └─flexplot:::flexplot_convert_to_categorical(data, axis)
    
  7.       └─base::factor(data[, axis[1]], ordered = T)
    
  8.         ├─base::unique(as.character(y)[ind])
    
  9.         ├─base::as.character(y)
    
  10.         └─vctrs:::as.character.vctrs_vctr(y)
    

Run rlang::last_trace(drop = FALSE) to see 11 hidden frames.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant