Problem with the function " lm "

Hello I have a problem with my "lm" function, here is what I am asked:
"We wonder if there is on average a significant difference in the alcohol levels measured between
white and red wines. Using linear regression, test if this is the case. Formulate your
null and alternative hypotheses and perform the test at the 5% threshold. "
So I simply start by importing my database:
vin <- read.csv("vin.csv",
header = TRUE,
sep = ",",
dec = ".")
then i want to use "lm" function like this: <- lm(Couleur ~ Alcool.mesure, data = vin)
but i have this error message:
"Error in, y, offset = offset, singular.ok = singular.ok, ...) :
NA/NaN/Inf dans 'y'
De plus : Warning message:
In storage.mode(v) <- "double" :
NAs introduits lors de la conversion automatique"
here is a screenshot of my database:

can you help me . have a nice day

Hi Jojorstui,

First, welcome to the R Studio Community forums.

I think that you get the error because the dependent numerical variable must be writed at the left of "~" symbol and the independent variables at the right. <- lm(Alcool.mesure ~ Couleur, data = vin)

Hope it helps.


1 Like

thank you very much I was really stuck on this exercise, thank you again have a nice day :slight_smile:

1 Like

This topic was automatically closed 7 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.