lessR

less work, more results for data analysis with R

  • library(lessR)
  • mydata <- Read("Mach4",
       format="lessR")
  • style("orange", sub.theme="black")
  • Plot(m06, m07,
       ellipse=TRUE, fit="loess")

This site provides support for doing data analysis with the R program using the functions in the package lessR, as documented by the accompanying text.

R Data Analysis without Programming
David W. Gerbing
Routledge/Taylor & Francis Publishing
December, 2014

The new look of data analysis output.

An R program overview of lessR input.

Both R and lessR are free and open source, and run identically on Macintosh, Windows and Linux/Unix computers.

Videos

Contents

  • 00:00 Intro
  • 00:50 Download and run R
  • 03:50 Download lessR and Library Function, run Help
  • 06:28 Install and run RStudio (optional)
  • Note: The .Rprofile file shown in the video must first be created, such as from RStudio with:
    File --> New File -> Text File

  • 09:20 Read Data, Data Tables, Missing Data
  • 20:57 lessR Function Names
  • 23:47 Histogram, The Manual for each Function
  • 28:08 BarChart
  • 29:22 t-test for the Mean Difference
  • 32:20 SummaryStats, Correlation and ScatterPlot
  • 33:55 Regression Analysis
  • 38:29 Output Object, Automatic Markdown
  • 46:24 Variable Transformations
  • 59:02 Standard R Functions

Major New Features

Any features added to lessR since August, 2013 are not presented in the book. Enter Help(lessR), then click on Package NEWS to see the full set of additions and bug fixes.

  • Plot. For any numeric variable, result is the newly developed VBS Plot, an integrated Violin/Box/Scatterplot, with the output tuned according to sample size and distribution characteristics. Replaces the pre-computer technology of the histogram with the modern alternative for the display of the distribution of a continuous variable. Trellis plots also available with the by1 and by2 parameters, plus the scatterplot can be shown more multiple groups on a single panel with the by parameter.
  • Plot. New parameter auto=TRUE adds much information to the 2-variable scatterplot.
  • Plot. MD.cut=0, out.cut=0 added to label outliers in box plot (part of the VBS plot) and two-variable scatterplots.
  • Plot, Histogram, Bar Chart. Trellis plots added with the by1 and by2 parameters.
  • Plot. Option topic added for analysis of means, counts, etc. instead of just the original data, and option object added to specify objects other than points.
  • BarChart. y parameter added to allow a bar chart of any y-variable with new parameter order -- x, y, by -- so by must now be explicitly indicated to specify a by variable
  • Plot. Revised function plots a scatter plot with any combination of one or more continuous (numeric) or categorical (non-numeric) variables.
  • new VariableLabels function. Can read variable labels from an external file apart from the Read function, and can also read the labels directly from the console.
  • RStudio and knitr compatible. lessR is now fully compatible with RStudio and knitr for processing R markdown files.
  • Automatic R Markdown. The knitr compatibility incentivized a new approach to output in which the output is now generated in segments, currently implemented for some functions, such as Regression, ANOVA, Histogram, Density, and ScatterPlot (1-variable). The segments are automatically collated for the output, or, can be stored in an object such as
    r <- reg(Y ~ X)
    To see the names of all the segments, enter
    names(r)
    referring to the name of the output object, here r. Then the segments can be listed separately, such as
    r$out_estimates
    In addition, the
    knitr.file
    option generates a specified knitr file that can be run with additional interpretative text. This option is currently available for Regression, Histogram (and BoxPlot, Density and ScatterPlot) and cfa functions.

    The interpretative output for Regression is well along in development. For example, the following code generates the R markdown file reg.Rmd.
    mydata <- rd("Reading", format="lessR")
    reg(Reading ~ Verbal + Absent + Income, knitr.file="reg")
    
    Process this markdown file, such as in RStudio with the knit button. This html is output from the knit procedure.
  • Read Excel data files. The lessR function Read can now directly read Excel data files. This functionality is from Hadley Wickham's readxl package. Both the main data file and/or the labels files can now be Excel files.
  • Browse for the variable labels file. The labels files in the Read statement can now be specified as labels="", which allows the user to browse for the labels file.
  • Variable labels added/modified directly. Variable labels can now be entered or modified directly with the label function in addition to the option of reading directly from a file.
  • Reduced Read output option. A brief version of the details function is now available for providing information about a data frame, called details.brief. This function is also called by Read and is invoked with the abbreviation rd.brief.
  • Analysis of multiple variables extended to Density and LineChart. An entire data frame or a list of variables defined as with the c function can now be specified for analysis with the Density and LineChart functions in addition to BarChart, BoxPlot, and Histogram.
  • Dependent-groups t-test plot. The ttest function, when applied to dependent groups with paired=TRUE, now provides a plot of each pair of data values in addition to the density plot of differences. This new plot includes a diagonal line that represents the equality of both values, and a line segment for each point to indicate the vertical distance from this line.

Data

1. The text files listed below for download can also be accessed directly from the web from within R with the following Read statement.

> mydata <- Read("http://lessRstats.com/data/name")

Replace name with the specific name of the file to access. Most of the text files are in csv format, for Comma Separated Values. Other text files are in the fwd format, for Fixed WiDth, in which the data values for a variable all occupy the same columns.

2. The SPSS versions of the data files are provided for SPSS users who can compare R/lessR with SPSS. The purpose is to show that data analysis with the lessR functions within the standard R environment is no more difficult that using SPSS in its GUI environment. And, by comparison, the R environment is much faster and more responsive, and, of course, free.

3. Files that are contained within lessR have already been downloaded when the lessR package was installed. To access any of these files from within R, use the Read function with the format option set to "lessR". For example, read a data table from the specified file into the data frame called mydata with the following R statement.

> mydata <- Read("name", format="lessR")

Replace name with the specific name of the file to download. The data files that are part of lessR are BodyMeas, Cars93, Employee, Learn, Mach4 and Reading. The Employee and Mach4 data tables already have the variable labels included.

Chapter 1: R for Data Analysis

Sec Text SPSS Description
1.6.5 employee.csv employee.sav Employee data table
1.6.6 Mach4.fwd Mach4.sav Responses to the 20-item Mach IV scale

Chapter 2: Read/Write Data

Sec Text SPSS Description
2.2.1 employee.csv employee.sav Employee data table
2.4 employee_lbl.csv Variable labels for employee data table, csv format
2.4 employee_lbl.xlsx Variable labels for employee data table, Excel format
2.6 HtWtEg.fwd Fixed width text data file for Exercise 2-3
2.6 Mach4Plus.fwd Fixed width text data file for Exercise 2-4. All items already reversed scored.

Chapter 3: Edit Data

Sec Text SPSS Description
3.7.1 Emp1a.csv First file to horizontal merge
3.7.1 Emp1b.csv Second file to horizontal merge
3.7.2 Emp2a.csv First file to vertical merge
3.7.2 Emp2b.csv Second file to vertical merge
3.8 Cars93.csv Data from 1993 cars for Exercise 3-2 to 5

Chapter 4: Categorical Variables

Sec Text SPSS Description
4.2 employee.csv employee.sav Employee data table
4.5 psych.csv Text data file for Exercises 4-1, 4-2 and 4-3

Chapter 5: Continuous Variables

Sec Text SPSS Description
5.6.1 Ratings.csv Time series data of student ratings of a professor
5.6.2 WorldPopulation.csv World population data over time
5.7 Cars93.csv Data from 1993 cars for Exercise 5-1
5.7 Mach4.fwd Mach4.sav Responses to the 20-item Mach IV scale, Exercise 5-2

Chapter 6: Means, Compare Two Samples

Sec Text SPSS Description
6.2.1 Mach4.fwd Mach4.sav Responses to the 20-item Mach IV scale, Exercise 5-2
6.3.4 Learn.csv Data for massed vs. distributed practice experiment
6.4.1 WeightLoss.csv Weight loss data
6.5 employee.csv employee.sav Employee data table for Exercise 6-1
6.5 Cars93.csv Data from 1993 cars for Exercise 6-2

Chapter 7: Compare Multiple Samples

Sec Text SPSS Description
7.2.1 anova_1way.csv One-way analysis of variance, unstacked data that needs to be reshaped first
7.2.1 anova_1way_stacked.csv One-way analysis of variance, stacked data ready for analysis
7.3.1 anova_rb.csv Randomized block analysis of variance
7.4.1 anova_2way.csv Two-way analysis of variance
7.5.1 anova_rbf.csv Randomized block factorial analysis of variance
7.5.2 anova_sp.csv Split-plot factorial analysis of variance
7.6 WeightLoss4.csv Weight loss data for Exercise 7-2
7.6 Anxiety.csv Anxiety data for Excercise 7-3

Chapter 8: Correlation

Sec Text SPSS Description
8.2.1 employee.csv employee.sav Employee data table
8.2.5 Mach4.fwd Mach4.sav Responses to the 20-item Mach IV scale
8.5 Cars93.csv Data from 1993 cars for Exercise 8-1

Chapter 9: Regression I

Sec Text SPSS Description
9.2.2 employee.csv employee.sav Employee data table
9.6 BodyMeas.csv Body measurements for Exercises 9-1 and 2
9.6 Cars93.csv Data from 1993 cars for Exercises 9-3

Chapter 10: Regression II

Sec Text SPSS Description
10.2.1 Reading.csv
10.5 BodyMeas.csv Body measurements for Exercise 10-1
10.5 Cars93.csv Data from 1993 cars for Exercise 10-2

Chapter 11: Factor/Item Analysis

Sec Text SPSS Description
11.3.2 Mach4.fwd Mach4.sav Responses to the 20-item Mach IV scale
11.5.2 MIMMperfect.cor Population correlation matrix for the specified measurement model
11.7 Mach4Plus.fwd Fixed width text data file for Exercises 11-1 and 2. All items already reversed scored.