Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara Logical Indexing | Section
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, ]).

Compito

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).

Soluzione

Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 1. Capitolo 37
single

single

Chieda ad AI

expand

Chieda ad AI

ChatGPT

Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione

close

bookLogical Indexing

Scorri per mostrare il menu

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, ]).

Compito

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).

Soluzione

Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 1. Capitolo 37
single

single

some-alt