Module lessons (1/2)
Data Frames and Subsetting
Construct data.frame(), inspect str()/summary(), extract columns with $, and filter rows with indexing [r, c].
What you'll learn in this lesson
- Create heterogeneous rectangular tables with
data.frame(..., stringsAsFactors = FALSE). - Quickly inspect schema, dimensions, and summaries via
str(),dim(),head(), andsummary(). - Extract columns as vectors (
df$col,df[["col"]]) distinguishing them from sub-tables (df["col"]). - Filter rows with boolean masks
[condizione, ]and add vectorized derived columns.
Overview
While a matrix imposes the same type on every cell, a data.frame is a list of vectors of equal length: each column can have its own atomic type (character for names, numeric for salaries, logical for states), just like a SQL table or a spreadsheet.
Before filtering or modeling data, an analyst always checks column sizes and types to quickly spot import errors or NA.
Sections covered in this lesson
- 1Creating and inspecting a Data Frame
- 2Extract columns (
$vs["col"]vs[["col"]]) and filter rows - 3Watch the tabular pipeline live
- 4Test yourself: guided exercises
- 5Concept check
Unlock "Data Frames and Subsetting" and the full Course R curriculum
Construct data.frame(), inspect str()/summary(), extract columns with $, and filter rows with indexing [r, c].
Unlock all 7 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.
- Instant access to all advanced modules in Course R plus 17 more courses
- Hands-on browser exercises with automated test suites and solutions
- 14-day money-back guarantee processed via Paddle.com
14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.