Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Logical Indexing | Section
Practice
Projects
Quizzes & Challenges
Quizzen
Challenges
/
Essential R Programming for Absolute Beginners - 1768563985826

bookLogical Indexing

Logical indexing allows you to filter rows of a data frame based on conditions. Instead of remembering row numbers, you specify logical expressions, and only rows where the condition is TRUE are returned.

Example

123456789
name <- c("Alex", "Julia", "Finn") age <- c(24, 43, 32) gender <- c("M", "F", "M") test <- data.frame(name, age, gender) # People older than 30 test[test$age > 30, ] # Males only test[test$gender == 'M', ]
copy

The condition should be placed in the row index position inside square brackets ([condition, ]).

Taak

Swipe to start coding

Using the mtcars dataset, extract the following data:

  1. The cars that pass a quarter-mile in less than 16 seconds (qsec column).
  2. Cars with 6 cylinders (cyl column).

Oplossing

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 1. Hoofdstuk 37
single

single

Vraag AI

expand

Vraag AI

ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

close

bookLogical Indexing

Veeg om het menu te tonen

Logical indexing allows you to filter rows of a data frame based on conditions. Instead of remembering row numbers, you specify logical expressions, and only rows where the condition is TRUE are returned.

Example

123456789
name <- c("Alex", "Julia", "Finn") age <- c(24, 43, 32) gender <- c("M", "F", "M") test <- data.frame(name, age, gender) # People older than 30 test[test$age > 30, ] # Males only test[test$gender == 'M', ]
copy

The condition should be placed in the row index position inside square brackets ([condition, ]).

Taak

Swipe to start coding

Using the mtcars dataset, extract the following data:

  1. The cars that pass a quarter-mile in less than 16 seconds (qsec column).
  2. Cars with 6 cylinders (cyl column).

Oplossing

Switch to desktopSchakel over naar desktop voor praktijkervaringGa verder vanaf waar je bent met een van de onderstaande opties
Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 1. Hoofdstuk 37
single

single

some-alt