── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(MASS)
Attaching package: 'MASS'
The following object is masked from 'package:dplyr':
select
data(msleep) #upload data setdf <- msleep
summary(df) #summary stats
name genus vore order
Length:83 Length:83 Length:83 Length:83
Class :character Class :character Class :character Class :character
Mode :character Mode :character Mode :character Mode :character
conservation sleep_total sleep_rem sleep_cycle
Length:83 Min. : 1.90 Min. :0.100 Min. :0.1167
Class :character 1st Qu.: 7.85 1st Qu.:0.900 1st Qu.:0.1833
Mode :character Median :10.10 Median :1.500 Median :0.3333
Mean :10.43 Mean :1.875 Mean :0.4396
3rd Qu.:13.75 3rd Qu.:2.400 3rd Qu.:0.5792
Max. :19.90 Max. :6.600 Max. :1.5000
NA's :22 NA's :51
awake brainwt bodywt
Min. : 4.10 Min. :0.00014 Min. : 0.005
1st Qu.:10.25 1st Qu.:0.00290 1st Qu.: 0.174
Median :13.90 Median :0.01240 Median : 1.670
Mean :13.57 Mean :0.28158 Mean : 166.136
3rd Qu.:16.15 3rd Qu.:0.12550 3rd Qu.: 41.750
Max. :22.10 Max. :5.71200 Max. :6654.000
NA's :27
str(df)
tibble [83 × 11] (S3: tbl_df/tbl/data.frame)
$ name : chr [1:83] "Cheetah" "Owl monkey" "Mountain beaver" "Greater short-tailed shrew" ...
$ genus : chr [1:83] "Acinonyx" "Aotus" "Aplodontia" "Blarina" ...
$ vore : chr [1:83] "carni" "omni" "herbi" "omni" ...
$ order : chr [1:83] "Carnivora" "Primates" "Rodentia" "Soricomorpha" ...
$ conservation: chr [1:83] "lc" NA "nt" "lc" ...
$ sleep_total : num [1:83] 12.1 17 14.4 14.9 4 14.4 8.7 7 10.1 3 ...
$ sleep_rem : num [1:83] NA 1.8 2.4 2.3 0.7 2.2 1.4 NA 2.9 NA ...
$ sleep_cycle : num [1:83] NA NA NA 0.133 0.667 ...
$ awake : num [1:83] 11.9 7 9.6 9.1 20 9.6 15.3 17 13.9 21 ...
$ brainwt : num [1:83] NA 0.0155 NA 0.00029 0.423 NA NA NA 0.07 0.0982 ...
$ bodywt : num [1:83] 50 0.48 1.35 0.019 600 ...
Call:
lm(formula = sleep_total ~ bodywt + vore + brainwt, data = clean_data)
Residuals:
Min 1Q Median 3Q Max
-5.6449 -2.6665 0.6286 2.1434 5.6449
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 13.761236 2.179664 6.313 1.91e-05 ***
bodywt -0.005898 0.015464 -0.381 0.709
voreherbi -2.060362 2.551881 -0.807 0.433
voreinsecti 0.297237 3.400524 0.087 0.932
voreomni -1.001401 2.700763 -0.371 0.716
brainwt -10.912003 15.500215 -0.704 0.493
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 3.694 on 14 degrees of freedom
Multiple R-squared: 0.5132, Adjusted R-squared: 0.3394
F-statistic: 2.952 on 5 and 14 DF, p-value: 0.05032
summary(clean_data)
name genus vore order
Length:20 Length:20 Length:20 Length:20
Class :character Class :character Class :character Class :character
Mode :character Mode :character Mode :character Mode :character
conservation sleep_total sleep_rem sleep_cycle
Length:20 Min. : 2.900 Min. :0.600 Min. :0.1167
Class :character 1st Qu.: 8.925 1st Qu.:1.300 1st Qu.:0.1792
Mode :character Median :11.300 Median :2.350 Median :0.2500
Mean :11.225 Mean :2.275 Mean :0.3458
3rd Qu.:13.925 3rd Qu.:3.125 3rd Qu.:0.4167
Max. :19.700 Max. :4.900 Max. :1.0000
awake brainwt bodywt
Min. : 4.30 Min. :0.00014 Min. : 0.0050
1st Qu.:10.07 1st Qu.:0.00115 1st Qu.: 0.0945
Median :12.70 Median :0.00590 Median : 0.7490
Mean :12.78 Mean :0.07882 Mean : 72.1177
3rd Qu.:15.07 3rd Qu.:0.03670 3rd Qu.: 6.1250
Max. :21.10 Max. :0.65500 Max. :600.0000