I am currently working on a project in which I have to run an ANCOVA test with the data set integrated in R. (Iris)
I am trying to figure out how to set up lm() in order to run this test. I do not want the complete answer, as I really want to learn.
So, basically I need to run an ANCOVA using the dataset iris in r. It is asking me to compare Sepal.Length
across all three species while adjusting for Sepal.Width
.
I have tried everything and nothing is working for me, and I know it's definitely user error.
I'm fairly new at using r, so please be nice.
I currently have:
fit2 <- lm(Sepal.Length ~ Species + Sepal.Width, data = iris_data)
I need to multiply the individual Species
times Sepal.width
on different occasions. I even created different objects so that I may multiply them times the width, but I have gotten countless of errors.
The current objects I have created are these:
setosa <- iris[iris$Species == "setosa", ]
versicolor <- iris[iris$Species == "versicolor", ]
virginica <- iris[iris$Species == "virginica", ]`
Please help steer me in the right direction, thank you! No complete answers, I just need to know how to set it up or maybe I'm unaware of a function that will help me out in this situation.
Any help is appreciated. Thank you