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:
# Linear Regression Project
# frequency of named hurricanes over time
# 1851-2022
# record variables and values - get into environment
NS <- c(6, 5, 8, 5, 5, 6, 4, 6, 8, 7, 8, 6, 9, 5, 7, 7, 9, 4, 10, 11, 8, 5, 5, 7, 6, 5, 8, 12, 8, 11, 7, 6, 4, 4, 8, 12, 19, 9, 9, 4, 10, 9, 12, 7, 6, 7, 6, 11, 10, 7, 13, 5, 10, 6, 5, 11, 5, 10, 12, 5, 6, 7, 6, 1, 6, 15, 4, 6, 5, 5, 7, 5, 9, 11, 4, 11, 8, 6, 5, 3, 13, 15, 20, 13, 8, 17, 11, 9, 6, 9, 6, 11, 10, 14, 11, 7, 10, 10, 16, 16, 12, 11, 14, 16, 13, 12, 8, 12, 14, 8, 12, 7, 10, 13, 10, 11, 8, 8, 18, 10, 13, 7, 8, 11, 9, 10, 6, 12, 9, 11, 12, 6, 4, 13, 11, 6, 7, 12, 11, 14, 8, 7, 8, 7, 19, 13, 8, 14, 12, 15, 15, 12, 16, 15, 28, 10, 15, 16, 9, 19, 19, 19, 14, 8, 11, 15, 17, 15, 18, 30, 21, 14)
YR<- c(1851:2022)
# next command created linear regression
LR <-lm(NS~YR)
summary(LR)
##
## Call:
## lm(formula = NS ~ YR)
##
## Residuals:
## Min 1Q Median 3Q Max
## -8.2491 -2.8462 -0.2045 1.8658 15.9058
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -86.638332 11.354784 -7.630 1.6e-12 ***
## YR 0.049868 0.005862 8.507 8.9e-15 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.817 on 170 degrees of freedom
## Multiple R-squared: 0.2986, Adjusted R-squared: 0.2945
## F-statistic: 72.38 on 1 and 170 DF, p-value: 8.896e-15
# next command creates scatter plot
plot(YR, NS)
# main = "Named Storms in the Atlantic", xlab ="", ylab = "Year", xlim = c(0.0,25.0), sub="Figure 1.
# Named Storms in the Atlantic 1851 - 2022")
abline(LR, col="red")
plot(YR,residuals(LR))
abline(a=0,b=0)
summary(cars) ```
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.