I've been learning R in R Studio and have been working on simple prediction modeling.
I receive the following error:
Invalid argument: 'sim' & 'obs' doesn't have the same length !
ncbabydata=read.csv("nc.csv",header=TRUE,stringsAsFactors = FALSE`)
model = train(weight ~.,trainingbabydata,method="rf")
Your two vectors are, in fact, not the same length:
> length(predictedWeight)  498 > length(testingbabydata$weight)  500
The reason for this is that some of your features are NA, and your prediction is simply omitting these rows. Handling missing data in models is a complex topic, but since it's only two rows out of 500, you can just remove them for now and continue your learning:
and you can then calculate your RMSE (which you can also do directly, without a helper):
> sqrt(mean((testingbabydata$weight-predictedWeight)^2))  1.025823
and you can compare it to a model which always predicts the mean value:
> sqrt(mean((testingbabydata$weight-mean(testingbabydata$weight))^2))  1.460638