liveBook · Manning

C() function

As explained in Statistics Slam Dunk

The c() function is a base R combining function that constructs a vector from multiple arguments.

The c() function is a base R combining function: pass multiple arguments to concatenate them into a vector. Vectors can supply variable positions, names, season values, or package names to other functions. section 2.3.1 section 3.2

Use c() in several practical data-preparation patterns:

  • Remove selected variables with dplyr::select() by placing a minus sign before c(), as in select(-c(off_loose_balls, def_loose_balls)). section 5.3
  • Filter out several values with %in% and logical negation: gini[!(gini$season_end %in% c(1985, 1986, 1987, 1988, 1989, 1990)),]. section 12.4
  • Pass several package names to lapply() after creating a character vector with c("tidyverse", "networkD3", "patchwork"). section 3.2

Dropping incomplete NBA seasons

The season_end values 1985 through 1990 become one vector, and %in% checks each row against that vector. Because ! negates the match, the resulting gini3 data excludes those seasons and contains 12,929 rows and three columns. section 12.4

draft <- select(draft,-c(3,4,16:24))

Inspect a compact select() example that removes draft-data columns by position using the negative c() pattern. section 2.3.1

How Statistics Slam Dunk covers it

How deep it goes
Defines argument combination and demonstrates it in select(), filtering, and lapply() workflows without discussing implementation internals.
Examples
Uses draft-column removal, NBA season exclusion, hustle-variable removal, and package-name vectors.
What it assumes
Assumes basic R function calls and data-frame operations while teaching vector construction through concrete wrangling examples.
What you can do after
Apply it via base R and dplyr to build vectors for selecting, excluding, and passing multiple values.
How it connects
Connects vectors with select(), filter(), %in%, logical negation, and lapply().

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Statistics Slam Dunk. The section links point to the parts of the book it draws on.