Error: unexpected ',' in "mylm=lm(`weight`~`pressure`, data=meter),"

data=lm(weight~pressure, data=meter), data$coefficients[1]

how can i fix it?

Erase the comma at the end of the first line

You need this on separate lines or to use a semi-colon.

Option 1:

data=lm(weight~pressure, data=meter)

Option 2:

data=lm(weight~pressure, data=meter); data$coefficients[1]

For R these options are identical, but Option 1 is easier to read for humans. Hence it is better stick to the Option 1.

Thank you so much for your helping

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