Skip to content
Learn Netverks

Lesson

Step 12/36 33% through track

data-frames-intro

Introduction to data frames

Last reviewed May 28, 2026 Content v20260528
Track mode
server_script
Means
Server runner
Reading
~1 min
Level
beginner

This lesson

An orientation to the R track—how the compiled playground works, core vocabulary, and what you will practice next.

You need a clear map of the R track so vectors, data frames, factors, and the tidyverse mindset do not feel like magic.

You will apply Introduction to data frames in contexts like: Research pipelines, Shiny dashboards, and statistical reporting.

Write R in the editor and click Run on server—the dev runner executes with Rscript; use print() or cat() and base R in playground snippets (tidyverse locally; LEARNING_RUNNER_ENABLED=true). Also read the interview prep blocks.

After basic programming and ideally SQL—pair with Python for ML-heavy roles or stay in R for stats and research pipelines.

A data frame is a tabular structure—rows are observations, columns are variables. It is the R equivalent of a spreadsheet or pandas DataFrame in Python.

Creating data frames

df <- data.frame(
  name = c("Ada", "Lin", "Sam"),
  score = c(92, 88, 95),
  passed = c(TRUE, TRUE, TRUE)
)
print(df)
print(nrow(df))
print(ncol(df))

Column access

print(df$name)
print(df[["score"]])
print(df[1, ])

$ and [[ ]] extract columns; [row, col] subsets rows and columns.

Important interview questions and answers

  1. Q: data.frame vs matrix?
    A: Data frames hold mixed column types; matrices are homogeneous 2D numeric/character.
  2. Q: Why stringsAsFactors changed?
    A: Older R coerced strings to factors by default; modern R keeps character columns unless requested.

Self-check

  1. How many rows does nrow(df) return?
  2. How do you access the score column with $?

Tip: data.frame is the hub—compare with pandas after your Python track.

Interview prep

data.frame vs matrix?

Data frames allow mixed column types; matrices are homogeneous 2D.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • data.frame vs tibble?
  • str() habit?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump