tidylsr 0.1.0
  • Reference
  • Articles
    • Running t-tests with tidylsr

Running t-tests with tidylsr

Source: vignettes/ttest.Rmd
ttest.Rmd
library(tidylsr)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union

A minimal example for the two sample test:

iris %>% 
  filter(Species != "versicolor") %>%
  ttest_twosample(Sepal.Length ~ Species)
#> 
#>     Welch's two sample t-test 
#> 
#> Variables: 
#>     outcome:  Sepal.Length 
#>     group:    Species 
#> 
#> Descriptives: 
#>     sample      mean        sd
#>     setosa     5.006     0.352
#>  virginica     6.588     0.636
#> 
#> Hypotheses: 
#>     null:         population means are equal 
#>     alternative:  population means are different 
#> 
#> Test results: 
#>     t-statistic:         -15.386 
#>     degrees of freedom:  76.516 
#>     p-value:             <.001 
#> 
#> 95% confidence interval:
#>     lower bound:  -1.787 
#>     upper bound:  -1.377

A minimal example for the one sample test:

iris %>% 
  filter(Species == "virginica") %>%
  ttest_onesample(outcome = Sepal.Length, null_mean = 6)
#> 
#>     One sample t-test 
#> 
#> Variables: 
#>     outcome:  Sepal.Length 
#> 
#> Descriptives: 
#>         sample      mean        sd
#>   Sepal.Length     6.588     0.636
#> 
#> Hypotheses: 
#>     null:         population mean equals 6 
#>     alternative:  population mean not equal to 6 
#> 
#> Test results: 
#>     t-statistic:         6.539 
#>     degrees of freedom:  49 
#>     p-value:             <.001 
#> 
#> 95% confidence interval:
#>     lower bound:  6.407 
#>     upper bound:  6.769

Developed by Danielle Navarro.

Site built with pkgdown 1.3.0.9100.