Learn R Programming

lsr

lsr is a companion package to the textbook Learning Statistics with R. It provides beginner-friendly wrappers for common statistical procedures — t-tests, chi-square tests, effect sizes, correlation matrices, and basic data manipulation — with output designed to be readable by students encountering statistics for the first time.

Example

Here is an independent-samples t-test comparing extra sleep between two drug groups in the built-in sleep dataset:

library(lsr)
independentSamplesTTest(formula = extra ~ group, data = sleep)
#> 
#>    Welch's independent samples t-test 
#> 
#> Outcome variable:   extra 
#> Grouping variable:  group 
#> 
#> Descriptive statistics: 
#>                 1     2
#>    mean     0.750 2.330
#>    std dev. 1.789 2.002
#> 
#> Hypotheses: 
#>    null:        population means equal for both groups
#>    alternative: different population means in each group
#> 
#> Test results: 
#>    t-statistic:  -1.861 
#>    degrees of freedom:  17.776 
#>    p-value:  0.079 
#> 
#> Other information: 
#>    two-sided 95% confidence interval:  [-3.365, 0.205] 
#>    estimated effect size (Cohen's d):  0.832

Compared to base R’s t.test(), the output labels every component in plain English and automatically reports Cohen’s d alongside the test result.

Where to go next

  • Guided overview — a hands-on introduction for students and beginners, working through descriptive statistics, reshaping data, and hypothesis testing with a single example dataset.
  • Critical commentary — an honest account of the package’s limitations and pointers to better tools for users who have outgrown it.
  • Reference — documentation for all 29 functions, organised by topic.

Installation

Install the released version from CRAN:

install.packages("lsr")

Or the development version from GitHub:

# install.packages("devtools")
devtools::install_github("djnavarro/lsr")

Copy Link

Version

Install

install.packages('lsr')

Monthly Downloads

6,659

Version

1.0.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Danielle Navarro

Last Published

July 11th, 2026

Functions in lsr (1.0.0)

importList

Import a list into the workspace
print.gofTest

Print goodness of fit test results
print.whoList

Print workspace summary
wideToLong

Reshape from wide to long
standardCoefs

Standardised regression coefficients
sortFrame

Sort a data frame
who

Contents of workspace
tFrame

Transpose a data frame
unlibrary

Unload a package
print.correlate

Print correlation matrix results
print.assocTest

Print chi-square association test results
quantileCut

Cut by quantiles
rmAll

Remove all objects from the workspace
etaSquared

Effect size for ANOVAs
ciMean

Confidence interval around the mean
correlate

Correlation matrices
expandFactors

Expand factors to a set of contrasts
cohensD

Cohen's d
bars

Grouped bar plots with error bars
copy

Copy a vector into a matrix
aad

Mean absolute deviation
mode

Sample mode
goodnessOfFitTest

Chi-square goodness of fit test
independentSamplesTTest

Independent samples t-test
print.TTest

Print t-test results
pairedSamplesTTest

Paired samples t-test
posthocPairwiseT

Post-hoc pairwise t-tests for ANOVA
cramersV

Cramer's V
associationTest

Chi-square test of association / independence
permuteLevels

Permute the levels of a factor
oneSampleTTest

One sample t-test
longToWide

Reshape from long to wide