R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

library(readr)
AgeHeight <- read_csv("C:/Users/Ceesay2032/Downloads/AgeHeight.xlsx")
## Multiple files in zip: reading '[Content_Types].xml'
## Rows: 1 Columns: 1
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
View(AgeHeight) 


library(readxl)

ageandheight <- read_excel("C:/Users/Ceesay2032/Downloads/AgeHeight.xlsx") #Upload the data 

ageandheight
## # A tibble: 12 × 3
##      age height no_siblings
##    <dbl>  <dbl>       <dbl>
##  1    18   76.1           1
##  2    19   77             2
##  3    20   78.1           3
##  4    21   78.2           2
##  5    22   78.8           0
##  6    23   79.7           1
##  7    24   79.9           5
##  8    25   81.1           0
##  9    26   81.2           1
## 10    27   81.8           4
## 11    28   82.8           1
## 12    29   83.5           5
lmHeight = lm(height~age, data = ageandheight) 

#Create the linear regression 

summary(lmHeight) 
## 
## Call:
## lm(formula = height ~ age, data = ageandheight)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.27238 -0.24248 -0.02762  0.16014  0.47238 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  64.9283     0.5084  127.71  < 2e-16 ***
## age           0.6350     0.0214   29.66 4.43e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.256 on 10 degrees of freedom
## Multiple R-squared:  0.9888, Adjusted R-squared:  0.9876 
## F-statistic:   880 on 1 and 10 DF,  p-value: 4.428e-11
#Review the results

#Review the results
  
lmHeight2 <- lm(height~age + no_siblings, data = ageandheight)
summary(lmHeight)
## 
## Call:
## lm(formula = height ~ age, data = ageandheight)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.27238 -0.24248 -0.02762  0.16014  0.47238 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  64.9283     0.5084  127.71  < 2e-16 ***
## age           0.6350     0.0214   29.66 4.43e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.256 on 10 degrees of freedom
## Multiple R-squared:  0.9888, Adjusted R-squared:  0.9876 
## F-statistic:   880 on 1 and 10 DF,  p-value: 4.428e-11

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.