Error in matrix(c(fobs, fmis), ncol = 2) : object 'fobs' not found

EN: I'm aware of how concrete and hard to answer my next question is, but it's literally the last issue I have to deal with to be done with my code. To sum things up, I'm studying missing data imputation by regression. My problem is when painting the graphic, I'm supposed to paint one with observed values and the other with imputed values. I'll add my code next so people can easily check it out. It gives me error and I don't know what to try anymore. Thank you so so much for giving this a try.

ES: soy consciente de que mi siguiente pregunta es bastante precisa y no fácil de contestar, pero es el último escollo para terminar mi código. De manera resumida, estoy estudiando la imputación de valores faltantes por método de imputación por regresión. Mi problema es al dibujar la gráfica que debe mostrar los valores observados y luego los imputados, y tengo el siguiente código en el que intentaré añadir todo para su fácil reproducibilidad. Cualquier ayuda es más que bienvenida, por favor y gracias.

df_nhan <- slice(filtered_nhan, 1:1000) %>%
  select(ID, Age, Gender, Weight, Height, TotChol, Diabetes, Pulse, PhysAct)

subsample <- slice(df_nhan, 1:1000) %>% select(Gender, Weight, Diabetes, PhysAct)

obs <- subsample$Weight
fobs <- c(hist(obs, breaks, plot=FALSE)$counts, 0)
# defino modelo y predicciones para subsample
fit <- lm(Weight ~ Diabetes, data = subsample)
pred <- predict(fit, newdata = ic(subsample))

# imputación alternativa utilizando MICE
imp <- mice(subsample[,1:2], method = "norm.predict", m=1, maxit=3, seed=1)

par(mfrow = c(1,2))
fmis <- c(hist(pred, breaks, plot = FALSE)$counts, 0)
y <- matrix(c(fobs, fmis), ncol =2)
matplot(x,y,type="s", col = c(mdc(4),mdc(5)),lwd=2, lty=1,xlim=c(0,170),ylim=c(0,45), yaxs = "i", xlab= "Weight", ylab= "Diabetes")

#segundo gráfico
tp <- xyplot(imp, Weight~Diabetes,
             ylab="Diabetes", xlab="Weight", cex = 0.75, lex=lwd,
             ylim = c(20, 180), xlim = c(0,100))
print(tp, newpage = FALSE, position = c(0.48,0.045,1,0.95))

could you export the data that I can use as a trial and the data that you want as an example?

Hi Rsky, data used is the library NHANES. By adding those first lines you access the dataframe, unless I'm misunderstanding your question. Sorry if that's the case, english is not my first language.