The equation of a linear function can be written as y=mx+b where m is the slope and b is the y intercept. y and x in this case serve as your independent and dependent variables.
to find the equation of the function using those points, substitute those values into y=mx+b.
y=-x+b
when you have one as the coefficient you can either write is as 1x or x and if it is negative it can be written as -1x or -x.
2= -1(4)+b
Substitute the x and y values into the equation along with the slope then solve for b.
2=-4+b
6=b
Then substitute your y intercept and slope into the slope equation, y=mx+b.
y=-x+6