Error in `$<-`: ! Assigned data `my_glm$fitted.values` must be compatible with existing data.

I'm trying to make a multivariate plot but once I try to specify my yhat:

statsproject_robert$yhat <- my_glm$fitted.values

I get the following error message:

Error in $<-:
! Assigned data my_glm$fitted.values must be compatible with existing data.
:heavy_multiplication_x: Existing data has 112 rows.
:heavy_multiplication_x: Assigned data has 100 rows.
:information_source: Only vectors of size 1 are recycled.
Caused by error in vectbl_recycle_rhs_rows():
! Can't recycle input of size 100 to size 112.
Run rlang::last_trace() to see where the error occurred.

This is the line of code but I don't know how to bypass the error values:

Additionally, if I wanted to use the log of some of the variables would I have to redefine the glm variable? Sorry for asking all these newbie questions, I'm still learning how to use R.

If you're sure that the missing values are all at the end

statsproject_robert$yhat[1:100] <- my_glm$fitted.values

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.