[R] Linear Regression line equation

Sarah Goslee sarah.goslee at gmail.com
Wed Sep 4 21:46:17 CEST 2013


summary(lm(Canopy_Height~Ground_Elevation, data=young400_1)) #use
data= instead of attach!

Or even

mylm <- lm(Canopy_Height~Ground_Elevation, data=young400_1)
mylm
summary(mylm)
coefficients(mylm)

Most intro to R guides cover the basics of modeling; you might benefit
from reading one of them.

Sarah


On Wed, Sep 4, 2013 at 1:35 PM, jfrei006 <jfrei006 at fiu.edu> wrote:
> First of I am new to using R.
>
> I have a dataset that I plotted using R, I created a scatter plot and used
> abline to create the line, what I need is to find the equation of the line.
> Below is the script I have used up until this point.
>
>>young400_1<-read.csv("Z:\\SOFTEL\\North Key Largo
> project\\Canopy_Height\\random_age_strat\\young400_1.csv")
>
>>attach(young400_1)
>>names(young400_1)
>
>>plot(Ground_Elevation,Canopy_Height,pch=16)
>
>>abline(lm(Canopy_Height~Ground_Elevation), col='red', main='Check the axis
> labels')
>
> This is where I'm stuck I don't know how to go about getting the equation to
> the line.
>
> My dataset is called young400_1 and it consist of 400 rows with 5 columns, I
> am only using 2 of the columns for the scatter plot; Ground_Elevation on the
> x axis and Canopy_Height on the y axis.
>
> Thanks in advance.
>
>
>
>
>

-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list