This page 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.
To install from CRAN:
install.packages('rmarkdown')
install.packages('knitr')
library(rmarkdown)
library(knitr)
This guide is a compilation of material from the following sources:
Cheatsheet: https://www.rstudio.com/wp-content/uploads/2016/03/rmarkdown-cheatsheet-2.0.pdf
Reference Guide: https://www.rstudio.com/wp-content/uploads/2015/03/rmarkdown-reference.pdf
Open ‘R Markdown’ under ‘File’, ‘New File’ in the main menu. Select ‘Document’ and ‘HTML’ output. To generate the output from an Rmd you will click the Knit button. This will produce an HTML document that includes both content as well as the output of any embedded R code chunks.
You can embed an R code chunk like this:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the previous code chunk header to prevent printing of the R code that generated the plot. Output can be customized with various knitr options set in the {} or a chunk header.
Options:
- echo = TRUE/FALSE; display code in output document
- error = TRUE/FALSE; whether or not to continue rendering when an error occurs
- eval = TRUE/FALSE; run code in chunk
- include = TRUE/FALSE; include code in output
- fig.align = ‘left’,‘right’,‘or ’center’
- fig.height or fig.width = plot dimensions in inches - warning = TRUE/FALSE; display code warnings in document
- message = TRUE/FALSE; include package messages etc in document
- results = TRUE/FALSE; ‘asis’, ‘hide’,‘or’hold’
- tidy = TRUE/FALSE - tidy code for display
More at: https://yihui.name/knitr/options/
Chunk options can also be set for the entire document. To do so, include in a chunk:
knitr::opts_chunk$set(error = TRUE, eval = TRUE, message = FALSE, warning = FALSE)
To quickly insert a chunk:
- press keyboard shortcut Cmd + Option = I (windows: Ctrl + Alt + I)
Reference Guide: https://www.rstudio.com/wp-content/uploads/2015/03/rmarkdown-reference.pdf
You can use familiar command so include the structure of your data
data(iris)
head(iris)
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1 5.1 3.5 1.4 0.2 setosa
## 2 4.9 3.0 1.4 0.2 setosa
## 3 4.7 3.2 1.3 0.2 setosa
## 4 4.6 3.1 1.5 0.2 setosa
## 5 5.0 3.6 1.4 0.2 setosa
## 6 5.4 3.9 1.7 0.4 setosa
str(iris)
## 'data.frame': 150 obs. of 5 variables:
## $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
## $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
## $ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
## $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
## $ Species : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ...
summary(iris)
## Sepal.Length Sepal.Width Petal.Length Petal.Width
## Min. :4.300 Min. :2.000 Min. :1.000 Min. :0.100
## 1st Qu.:5.100 1st Qu.:2.800 1st Qu.:1.600 1st Qu.:0.300
## Median :5.800 Median :3.000 Median :4.350 Median :1.300
## Mean :5.843 Mean :3.057 Mean :3.758 Mean :1.199
## 3rd Qu.:6.400 3rd Qu.:3.300 3rd Qu.:5.100 3rd Qu.:1.800
## Max. :7.900 Max. :4.400 Max. :6.900 Max. :2.500
## Species
## setosa :50
## versicolor:50
## virginica :50
##
##
##
dput(iris)
## structure(list(Sepal.Length = c(5.1, 4.9, 4.7, 4.6, 5, 5.4, 4.6,
## 5, 4.4, 4.9, 5.4, 4.8, 4.8, 4.3, 5.8, 5.7, 5.4, 5.1, 5.7, 5.1,
## 5.4, 5.1, 4.6, 5.1, 4.8, 5, 5, 5.2, 5.2, 4.7, 4.8, 5.4, 5.2,
## 5.5, 4.9, 5, 5.5, 4.9, 4.4, 5.1, 5, 4.5, 4.4, 5, 5.1, 4.8, 5.1,
## 4.6, 5.3, 5, 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, 2L, 2L, 2L, 2L,
## 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L,
## 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
## 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
## 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
## 3L), .Label = c("setosa", "versicolor", "virginica"), class = "factor")), .Names = c("Sepal.Length",
## "Sepal.Width", "Petal.Length", "Petal.Width", "Species"), row.names = c(NA,
## -150L), class = "data.frame")
or using HTML widgets to make them interactive:
http://www.htmlwidgets.org/showcase_datatables.html
install.packages('DT')
library(DT)
datatable(iris)
See the DT gituhub page for more customizations
https://rstudio.github.io/DT/
Include description of data, show structure
fit<-lm(Sepal.Length~Species, data=iris)
fit
##
## Call:
## lm(formula = Sepal.Length ~ Species, data = iris)
##
## Coefficients:
## (Intercept) Speciesversicolor Speciesvirginica
## 5.006 0.930 1.582
summary(fit)
##
## Call:
## lm(formula = Sepal.Length ~ Species, data = iris)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.6880 -0.3285 -0.0060 0.3120 1.3120
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.0060 0.0728 68.762 < 2e-16 ***
## Speciesversicolor 0.9300 0.1030 9.033 8.77e-16 ***
## Speciesvirginica 1.5820 0.1030 15.366 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5148 on 147 degrees of freedom
## Multiple R-squared: 0.6187, Adjusted R-squared: 0.6135
## F-statistic: 119.3 on 2 and 147 DF, p-value: < 2.2e-16
summary(aov(fit))
## Df Sum Sq Mean Sq F value Pr(>F)
## Species 2 63.21 31.606 119.3 <2e-16 ***
## Residuals 147 38.96 0.265
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
broom - Tidy up messy outputs https://cran.r-project.org/web/packages/broom/vignettes/broom.html
install.packages('broom')
library(broom)
tidy - returns a dataframe with results, coefficients
tidy(fit)
## term estimate std.error statistic p.value
## 1 (Intercept) 5.006 0.07280222 68.761639 1.134286e-113
## 2 Speciesversicolor 0.930 0.10295789 9.032819 8.770194e-16
## 3 Speciesvirginica 1.582 0.10295789 15.365506 2.214821e-32
augment - returns a dataframe with fitted values and residuals for original points in the regression
augment(fit)
## Sepal.Length Species .fitted .se.fit .resid .hat .sigma
## 1 5.1 setosa 5.006 0.07280222 0.094 0.02 0.5164896
## 2 4.9 setosa 5.006 0.07280222 -0.106 0.02 0.5164734
## 3 4.7 setosa 5.006 0.07280222 -0.306 0.02 0.5159156
## 4 4.6 setosa 5.006 0.07280222 -0.406 0.02 0.5154331
## 5 5.0 setosa 5.006 0.07280222 -0.006 0.02 0.5165492
## 6 5.4 setosa 5.006 0.07280222 0.394 0.02 0.5154981
## 7 4.6 setosa 5.006 0.07280222 -0.406 0.02 0.5154331
## 8 5.0 setosa 5.006 0.07280222 -0.006 0.02 0.5165492
## 9 4.4 setosa 5.006 0.07280222 -0.606 0.02 0.5140590
## 10 4.9 setosa 5.006 0.07280222 -0.106 0.02 0.5164734
## 11 5.4 setosa 5.006 0.07280222 0.394 0.02 0.5154981
## 12 4.8 setosa 5.006 0.07280222 -0.206 0.02 0.5162622
## 13 4.8 setosa 5.006 0.07280222 -0.206 0.02 0.5162622
## 14 4.3 setosa 5.006 0.07280222 -0.706 0.02 0.5131663
## 15 5.8 setosa 5.006 0.07280222 0.794 0.02 0.5122666
## 16 5.7 setosa 5.006 0.07280222 0.694 0.02 0.5132807
## 17 5.4 setosa 5.006 0.07280222 0.394 0.02 0.5154981
## 18 5.1 setosa 5.006 0.07280222 0.094 0.02 0.5164896
## 19 5.7 setosa 5.006 0.07280222 0.694 0.02 0.5132807
## 20 5.1 setosa 5.006 0.07280222 0.094 0.02 0.5164896
## 21 5.4 setosa 5.006 0.07280222 0.394 0.02 0.5154981
## 22 5.1 setosa 5.006 0.07280222 0.094 0.02 0.5164896
## 23 4.6 setosa 5.006 0.07280222 -0.406 0.02 0.5154331
## 24 5.1 setosa 5.006 0.07280222 0.094 0.02 0.5164896
## 25 4.8 setosa 5.006 0.07280222 -0.206 0.02 0.5162622
## 26 5.0 setosa 5.006 0.07280222 -0.006 0.02 0.5165492
## 27 5.0 setosa 5.006 0.07280222 -0.006 0.02 0.5165492
## 28 5.2 setosa 5.006 0.07280222 0.194 0.02 0.5162947
## 29 5.2 setosa 5.006 0.07280222 0.194 0.02 0.5162947
## 30 4.7 setosa 5.006 0.07280222 -0.306 0.02 0.5159156
## 31 4.8 setosa 5.006 0.07280222 -0.206 0.02 0.5162622
## 32 5.4 setosa 5.006 0.07280222 0.394 0.02 0.5154981
## 33 5.2 setosa 5.006 0.07280222 0.194 0.02 0.5162947
## 34 5.5 setosa 5.006 0.07280222 0.494 0.02 0.5148958
## 35 4.9 setosa 5.006 0.07280222 -0.106 0.02 0.5164734
## 36 5.0 setosa 5.006 0.07280222 -0.006 0.02 0.5165492
## 37 5.5 setosa 5.006 0.07280222 0.494 0.02 0.5148958
## 38 4.9 setosa 5.006 0.07280222 -0.106 0.02 0.5164734
## 39 4.4 setosa 5.006 0.07280222 -0.606 0.02 0.5140590
## 40 5.1 setosa 5.006 0.07280222 0.094 0.02 0.5164896
## 41 5.0 setosa 5.006 0.07280222 -0.006 0.02 0.5165492
## 42 4.5 setosa 5.006 0.07280222 -0.506 0.02 0.5148144
## 43 4.4 setosa 5.006 0.07280222 -0.606 0.02 0.5140590
## 44 5.0 setosa 5.006 0.07280222 -0.006 0.02 0.5165492
## 45 5.1 setosa 5.006 0.07280222 0.094 0.02 0.5164896
## 46 4.8 setosa 5.006 0.07280222 -0.206 0.02 0.5162622
## 47 5.1 setosa 5.006 0.07280222 0.094 0.02 0.5164896
## 48 4.6 setosa 5.006 0.07280222 -0.406 0.02 0.5154331
## 49 5.3 setosa 5.006 0.07280222 0.294 0.02 0.5159643
## 50 5.0 setosa 5.006 0.07280222 -0.006 0.02 0.5165492
## 51 7.0 versicolor 5.936 0.07280222 1.064 0.02 0.5088329
## 52 6.4 versicolor 5.936 0.07280222 0.464 0.02 0.5150908
## 53 6.9 versicolor 5.936 0.07280222 0.964 0.02 0.5102238
## 54 5.5 versicolor 5.936 0.07280222 -0.436 0.02 0.5152618
## 55 6.5 versicolor 5.936 0.07280222 0.564 0.02 0.5143929
## 56 5.7 versicolor 5.936 0.07280222 -0.236 0.02 0.5161725
## 57 6.3 versicolor 5.936 0.07280222 0.364 0.02 0.5156523
## 58 4.9 versicolor 5.936 0.07280222 -1.036 0.02 0.5092366
## 59 6.6 versicolor 5.936 0.07280222 0.664 0.02 0.5135580
## 60 5.2 versicolor 5.936 0.07280222 -0.736 0.02 0.5128716
## 61 5.0 versicolor 5.936 0.07280222 -0.936 0.02 0.5105881
## 62 5.9 versicolor 5.936 0.07280222 -0.036 0.02 0.5165406
## 63 6.0 versicolor 5.936 0.07280222 0.064 0.02 0.5165217
## 64 6.1 versicolor 5.936 0.07280222 0.164 0.02 0.5163674
## 65 5.6 versicolor 5.936 0.07280222 -0.336 0.02 0.5157851
## 66 6.7 versicolor 5.936 0.07280222 0.764 0.02 0.5125854
## 67 5.6 versicolor 5.936 0.07280222 -0.336 0.02 0.5157851
## 68 5.8 versicolor 5.936 0.07280222 -0.136 0.02 0.5164243
## 69 6.2 versicolor 5.936 0.07280222 0.264 0.02 0.5160777
## 70 5.6 versicolor 5.936 0.07280222 -0.336 0.02 0.5157851
## 71 5.9 versicolor 5.936 0.07280222 -0.036 0.02 0.5165406
## 72 6.1 versicolor 5.936 0.07280222 0.164 0.02 0.5163674
## 73 6.3 versicolor 5.936 0.07280222 0.364 0.02 0.5156523
## 74 6.1 versicolor 5.936 0.07280222 0.164 0.02 0.5163674
## 75 6.4 versicolor 5.936 0.07280222 0.464 0.02 0.5150908
## 76 6.6 versicolor 5.936 0.07280222 0.664 0.02 0.5135580
## 77 6.8 versicolor 5.936 0.07280222 0.864 0.02 0.5114743
## 78 6.7 versicolor 5.936 0.07280222 0.764 0.02 0.5125854
## 79 6.0 versicolor 5.936 0.07280222 0.064 0.02 0.5165217
## 80 5.7 versicolor 5.936 0.07280222 -0.236 0.02 0.5161725
## 81 5.5 versicolor 5.936 0.07280222 -0.436 0.02 0.5152618
## 82 5.5 versicolor 5.936 0.07280222 -0.436 0.02 0.5152618
## 83 5.8 versicolor 5.936 0.07280222 -0.136 0.02 0.5164243
## 84 6.0 versicolor 5.936 0.07280222 0.064 0.02 0.5165217
## 85 5.4 versicolor 5.936 0.07280222 -0.536 0.02 0.5146021
## 86 6.0 versicolor 5.936 0.07280222 0.064 0.02 0.5165217
## 87 6.7 versicolor 5.936 0.07280222 0.764 0.02 0.5125854
## 88 6.3 versicolor 5.936 0.07280222 0.364 0.02 0.5156523
## 89 5.6 versicolor 5.936 0.07280222 -0.336 0.02 0.5157851
## 90 5.5 versicolor 5.936 0.07280222 -0.436 0.02 0.5152618
## 91 5.5 versicolor 5.936 0.07280222 -0.436 0.02 0.5152618
## 92 6.1 versicolor 5.936 0.07280222 0.164 0.02 0.5163674
## 93 5.8 versicolor 5.936 0.07280222 -0.136 0.02 0.5164243
## 94 5.0 versicolor 5.936 0.07280222 -0.936 0.02 0.5105881
## 95 5.6 versicolor 5.936 0.07280222 -0.336 0.02 0.5157851
## 96 5.7 versicolor 5.936 0.07280222 -0.236 0.02 0.5161725
## 97 5.7 versicolor 5.936 0.07280222 -0.236 0.02 0.5161725
## 98 6.2 versicolor 5.936 0.07280222 0.264 0.02 0.5160777
## 99 5.1 versicolor 5.936 0.07280222 -0.836 0.02 0.5117994
## 100 5.7 versicolor 5.936 0.07280222 -0.236 0.02 0.5161725
## 101 6.3 virginica 6.588 0.07280222 -0.288 0.02 0.5159880
## 102 5.8 virginica 6.588 0.07280222 -0.788 0.02 0.5123314
## 103 7.1 virginica 6.588 0.07280222 0.512 0.02 0.5147729
## 104 6.3 virginica 6.588 0.07280222 -0.288 0.02 0.5159880
## 105 6.5 virginica 6.588 0.07280222 -0.088 0.02 0.5164970
## 106 7.6 virginica 6.588 0.07280222 1.012 0.02 0.5095738
## 107 4.9 virginica 6.588 0.07280222 -1.688 0.02 0.4968993
## 108 7.3 virginica 6.588 0.07280222 0.712 0.02 0.5131084
## 109 6.7 virginica 6.588 0.07280222 0.112 0.02 0.5164645
## 110 7.2 virginica 6.588 0.07280222 0.612 0.02 0.5140093
## 111 6.5 virginica 6.588 0.07280222 -0.088 0.02 0.5164970
## 112 6.4 virginica 6.588 0.07280222 -0.188 0.02 0.5163102
## 113 6.8 virginica 6.588 0.07280222 0.212 0.02 0.5162453
## 114 5.7 virginica 6.588 0.07280222 -0.888 0.02 0.5111869
## 115 5.8 virginica 6.588 0.07280222 -0.788 0.02 0.5123314
## 116 6.4 virginica 6.588 0.07280222 -0.188 0.02 0.5163102
## 117 6.5 virginica 6.588 0.07280222 -0.088 0.02 0.5164970
## 118 7.7 virginica 6.588 0.07280222 1.112 0.02 0.5081151
## 119 7.7 virginica 6.588 0.07280222 1.112 0.02 0.5081151
## 120 6.0 virginica 6.588 0.07280222 -0.588 0.02 0.5142051
## 121 6.9 virginica 6.588 0.07280222 0.312 0.02 0.5158904
## 122 5.6 virginica 6.588 0.07280222 -0.988 0.02 0.5099029
## 123 7.7 virginica 6.588 0.07280222 1.112 0.02 0.5081151
## 124 6.3 virginica 6.588 0.07280222 -0.288 0.02 0.5159880
## 125 6.7 virginica 6.588 0.07280222 0.112 0.02 0.5164645
## 126 7.2 virginica 6.588 0.07280222 0.612 0.02 0.5140093
## 127 6.2 virginica 6.588 0.07280222 -0.388 0.02 0.5155299
## 128 6.1 virginica 6.588 0.07280222 -0.488 0.02 0.5149358
## 129 6.4 virginica 6.588 0.07280222 -0.188 0.02 0.5163102
## 130 7.2 virginica 6.588 0.07280222 0.612 0.02 0.5140093
## 131 7.4 virginica 6.588 0.07280222 0.812 0.02 0.5120694
## 132 7.9 virginica 6.588 0.07280222 1.312 0.02 0.5047699
## 133 6.4 virginica 6.588 0.07280222 -0.188 0.02 0.5163102
## 134 6.3 virginica 6.588 0.07280222 -0.288 0.02 0.5159880
## 135 6.1 virginica 6.588 0.07280222 -0.488 0.02 0.5149358
## 136 7.7 virginica 6.588 0.07280222 1.112 0.02 0.5081151
## 137 6.3 virginica 6.588 0.07280222 -0.288 0.02 0.5159880
## 138 6.4 virginica 6.588 0.07280222 -0.188 0.02 0.5163102
## 139 6.0 virginica 6.588 0.07280222 -0.588 0.02 0.5142051
## 140 6.9 virginica 6.588 0.07280222 0.312 0.02 0.5158904
## 141 6.7 virginica 6.588 0.07280222 0.112 0.02 0.5164645
## 142 6.9 virginica 6.588 0.07280222 0.312 0.02 0.5158904
## 143 5.8 virginica 6.588 0.07280222 -0.788 0.02 0.5123314
## 144 6.8 virginica 6.588 0.07280222 0.212 0.02 0.5162453
## 145 6.7 virginica 6.588 0.07280222 0.112 0.02 0.5164645
## 146 6.7 virginica 6.588 0.07280222 0.112 0.02 0.5164645
## 147 6.3 virginica 6.588 0.07280222 -0.288 0.02 0.5159880
## 148 6.5 virginica 6.588 0.07280222 -0.088 0.02 0.5164970
## 149 6.2 virginica 6.588 0.07280222 -0.388 0.02 0.5155299
## 150 5.9 virginica 6.588 0.07280222 -0.688 0.02 0.5133372
## .cooksd .std.resid
## 1 2.314478e-04 0.18445277
## 2 2.943127e-04 -0.20799994
## 3 2.452676e-03 -0.60045265
## 4 4.317670e-03 -0.79667900
## 5 9.429743e-07 -0.01177358
## 6 4.066210e-03 0.77313184
## 7 4.317670e-03 -0.79667900
## 8 9.429743e-07 -0.01177358
## 9 9.619280e-03 -1.18913171
## 10 2.943127e-04 -0.20799994
## 11 4.066210e-03 0.77313184
## 12 1.111557e-03 -0.40422629
## 13 1.111557e-03 -0.40422629
## 14 1.305590e-02 -1.38535806
## 15 1.651347e-02 1.55803726
## 16 1.261584e-02 1.36181090
## 17 4.066210e-03 0.77313184
## 18 2.314478e-04 0.18445277
## 19 1.261584e-02 1.36181090
## 20 2.314478e-04 0.18445277
## 21 4.066210e-03 0.77313184
## 22 2.314478e-04 0.18445277
## 23 4.317670e-03 -0.79667900
## 24 2.314478e-04 0.18445277
## 25 1.111557e-03 -0.40422629
## 26 9.429743e-07 -0.01177358
## 27 9.429743e-07 -0.01177358
## 28 9.858272e-04 0.38067913
## 29 9.858272e-04 0.38067913
## 30 2.452676e-03 -0.60045265
## 31 1.111557e-03 -0.40422629
## 32 4.066210e-03 0.77313184
## 33 9.858272e-04 0.38067913
## 34 6.392213e-03 0.96935819
## 35 2.943127e-04 -0.20799994
## 36 9.429743e-07 -0.01177358
## 37 6.392213e-03 0.96935819
## 38 2.943127e-04 -0.20799994
## 39 9.619280e-03 -1.18913171
## 40 2.314478e-04 0.18445277
## 41 9.429743e-07 -0.01177358
## 42 6.706538e-03 -0.99290535
## 43 9.619280e-03 -1.18913171
## 44 9.429743e-07 -0.01177358
## 45 2.314478e-04 0.18445277
## 46 1.111557e-03 -0.40422629
## 47 2.314478e-04 0.18445277
## 48 4.317670e-03 -0.79667900
## 49 2.264081e-03 0.57690548
## 50 9.429743e-07 -0.01177358
## 51 2.965382e-02 2.08784841
## 52 5.639405e-03 0.91049029
## 53 2.434173e-02 1.89162206
## 54 4.979323e-03 -0.85554691
## 55 8.332121e-03 1.10671664
## 56 1.458886e-03 -0.46309420
## 57 3.470564e-03 0.71426393
## 58 2.811363e-02 -2.03290504
## 59 1.154871e-02 1.30294300
## 60 1.418904e-02 -1.44422597
## 61 2.294822e-02 -1.83667868
## 62 3.394707e-05 -0.07064149
## 63 1.072895e-04 0.12558487
## 64 7.045065e-04 0.32181122
## 65 2.957167e-03 -0.65932055
## 66 1.528918e-02 1.49916935
## 67 2.957167e-03 -0.65932055
## 68 4.844792e-04 -0.26686784
## 69 1.825598e-03 0.51803758
## 70 2.957167e-03 -0.65932055
## 71 3.394707e-05 -0.07064149
## 72 7.045065e-04 0.32181122
## 73 3.470564e-03 0.71426393
## 74 7.045065e-04 0.32181122
## 75 5.639405e-03 0.91049029
## 76 1.154871e-02 1.30294300
## 77 1.955351e-02 1.69539570
## 78 1.528918e-02 1.49916935
## 79 1.072895e-04 0.12558487
## 80 1.458886e-03 -0.46309420
## 81 4.979323e-03 -0.85554691
## 82 4.979323e-03 -0.85554691
## 83 4.844792e-04 -0.26686784
## 84 1.072895e-04 0.12558487
## 85 7.525354e-03 -1.05177326
## 86 1.072895e-04 0.12558487
## 87 1.528918e-02 1.49916935
## 88 3.470564e-03 0.71426393
## 89 2.957167e-03 -0.65932055
## 90 4.979323e-03 -0.85554691
## 91 4.979323e-03 -0.85554691
## 92 7.045065e-04 0.32181122
## 93 4.844792e-04 -0.26686784
## 94 2.294822e-02 -1.83667868
## 95 2.957167e-03 -0.65932055
## 96 1.458886e-03 -0.46309420
## 97 1.458886e-03 -0.46309420
## 98 1.825598e-03 0.51803758
## 99 1.830669e-02 -1.64045233
## 100 1.458886e-03 -0.46309420
## 101 2.172613e-03 -0.56513190
## 102 1.626484e-02 -1.54626368
## 103 6.866529e-03 1.00467894
## 104 2.172613e-03 -0.56513190
## 105 2.028442e-04 -0.17267919
## 106 2.682615e-02 1.98581071
## 107 7.463495e-02 -3.31230087
## 108 1.327875e-02 1.39713165
## 109 3.285741e-04 0.21977352
## 110 9.810704e-03 1.20090529
## 111 2.028442e-04 -0.17267919
## 112 9.257912e-04 -0.36890555
## 113 1.177251e-03 0.41599987
## 114 2.065491e-02 -1.74249003
## 115 1.626484e-02 -1.54626368
## 116 9.257912e-04 -0.36890555
## 117 2.028442e-04 -0.17267919
## 118 3.238970e-02 2.18203706
## 119 3.238970e-02 2.18203706
## 120 9.056325e-03 -1.15381097
## 121 2.549802e-03 0.61222623
## 122 2.556885e-02 -1.93871638
## 123 3.238970e-02 2.18203706
## 124 2.172613e-03 -0.56513190
## 125 3.285741e-04 0.21977352
## 126 9.810704e-03 1.20090529
## 127 3.943309e-03 -0.76135826
## 128 6.237880e-03 -0.95758461
## 129 9.257912e-04 -0.36890555
## 130 9.810704e-03 1.20090529
## 131 1.727068e-02 1.59335800
## 132 4.508842e-02 2.57448977
## 133 9.257912e-04 -0.36890555
## 134 2.172613e-03 -0.56513190
## 135 6.237880e-03 -0.95758461
## 136 3.238970e-02 2.18203706
## 137 2.172613e-03 -0.56513190
## 138 9.257912e-04 -0.36890555
## 139 9.056325e-03 -1.15381097
## 140 2.549802e-03 0.61222623
## 141 3.285741e-04 0.21977352
## 142 2.549802e-03 0.61222623
## 143 1.626484e-02 -1.54626368
## 144 1.177251e-03 0.41599987
## 145 3.285741e-04 0.21977352
## 146 3.285741e-04 0.21977352
## 147 2.172613e-03 -0.56513190
## 148 2.028442e-04 -0.17267919
## 149 3.943309e-03 -0.76135826
## 150 1.239864e-02 -1.35003732
glance - returns a dataframe with summary statistics R2 and F-stat
glance(fit)
## r.squared adj.r.squared sigma statistic p.value df logLik
## 1 0.6187057 0.6135181 0.5147894 119.2645 1.669669e-31 3 -111.726
## AIC BIC deviance df.residual
## 1 231.452 243.4945 38.9562 147
Add results of statistical test to rmd
Produce and annotate a plot using the dust data
You can make figures interactive and very web friendly using plotly.
https://plot.ly/r/