I'm getting the following error when I run the plot code: Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' and 'y' lengths differ
. I have many NA
s in my data set which I understand is causing the problem. Any ideas as to:
- how to deal with NAs in R, and
- how to make sure I can plot plots of variables with differing lengths?
I looked at some similar questions posted here, but unfortunately couldn't make sense of it. Needless to say, I'm new to R.
df <- read.dta("r12.dta")
attach(df)
model1 <- lm(rent~I(income^2)+income*races)
fitted(model1)
layout(matrix(1:4,2,2))
plot(model1)
plot(income, fitted(model1), xlab="Income", ylab="Rent",
main="Fitted Values for Black Rent",type="l")