Adding regression to scatter plot in R -


i want add regression scatter plot in r , make elevation independent while snowfall dependent. know how construct simple scatter plot - using regression , making elevation independent while snowfall dependent - stuck with... many thanks!

code have far create simple scatter plot:

> elevation=c(12, 34, 32, 12, 11, 14, 56, 75, 43) > snowfall=c(6, 52, 41, 25, 22, 9, 43, 67, 32) > snowfallelevationplot = data.frame(elevation=elevation, snowfall=snowfall) > plot(elevation, snowfall) 

use abline in:

# estimating model model <-  lm(snowfall~elevation, data=snowfallelevationplot)  # plot  plot(elevation, snowfall)  # adding regression line plot abline(model) 

this produces

enter image description here


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -