Data frames in R
The rectangular table at the center of R analysis.
people <- data.frame(
name = c("ada", "grace", "kay"),
score = c(95, 88, 92),
stringsAsFactors = FALSE
)
shape <- dim(people)
columns <- names(people)
first_rows <- head(people, 2)
structure <- str(people)
people$passed <- people$score >= 90
one_cell <- people[2, "score"]
How it works
data.framebuilds one column by column.dim,names,head, andstrinspect it.df$new <- ...adds a computed column.
Keywords and builtins used here
cdimheadnamesstr
The run, in numbers
- Lines
- 13
- Characters to type
- 274
- Tokens
- 77
- Three-star pace
- 90 tpm
At the three-star pace of 90 tokens a minute, this run takes about 51 seconds.
Step 1 of 3 in Building & inspecting, step 1 of 8 in Data frames in base R.