ycliper

Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
Скачать

How To Use ifelse in R

Автор: DataDaft

Загружено: 2019-09-04

Просмотров: 30283

Описание: The ifelse function in R lets you perform conditional logic on vectors, doing one thing with certain values and something else with other values. It is a more efficient to use ifelse in R than it is to use explicit for loops to go through a vector and perform operations sequentially because ifelse in R is performed in a vectorized fashion, meaning the operation is carried out all at once instead of by going through each value one at a time.


Code used in this clip:

Data with bad values
data <- c(11, 7, NA, 9, NA, 13, 15, NaN, 19, 17, 14, NaN)

Use ifelse to conditionally fill bad values with the mean

ifelse(is.na(data)|is.nan(data), # logical check
mean(data, na.rm = T), # value to set if TRUE
data) # value to set if FALSE


Chaining ifelse to perform multiple operations

d <- ifelse(is.na(data)|is.nan(data), "missing",
ifelse(data < 10, "low",
ifelse(data < 15, "medium", "high")))

d
table(d)

Code Clips are basic code explanations in 3 minutes or less. They are intended to be short reference guides that provide quick breakdowns and copy/paste access to code needed to accomplish common data science tasks. Think Stack Overflow with a video explanation.


Note: YouTube does not allow greater than or less than symbols in the text description, so the code above will not be exactly the same as the code shown in the video! For R that means I may use = for assignment and the special Unicode large < and > symbols in place of the standard sized ones for dplyr pipes and comparisons. These special symbols should work as expected for R code on Windows, but may need to be replaced with standard greater than and less than symbols for other operating systems.

Не удается загрузить Youtube-плеер. Проверьте блокировку Youtube в вашей сети.
Повторяем попытку...
How To Use ifelse in R

Поделиться в:

Доступные форматы для скачивания:

Скачать видео

  • Информация по загрузке:

Скачать аудио

Похожие видео

How to Read csv Data Into R

How to Read csv Data Into R

If-else statements in R

If-else statements in R

Conditional Statements in R:   if_else() and case_when() Functions

Conditional Statements in R: if_else() and case_when() Functions

Условные операторы в R (If, Else If и Else)

Условные операторы в R (If, Else If и Else)

Introduction to R: Matrices

Introduction to R: Matrices

УЧЕБНОЕ ПОСОБИЕ ПО R Markdown | Мощный инструмент для ИЗУЧЕНИЯ R (ЗА ​​45 МИНУТ)

УЧЕБНОЕ ПОСОБИЕ ПО R Markdown | Мощный инструмент для ИЗУЧЕНИЯ R (ЗА ​​45 МИНУТ)

Dplyr Essentials (easy data manipulation in R): select, mutate, filter, group_by, summarise, & more

Dplyr Essentials (easy data manipulation in R): select, mutate, filter, group_by, summarise, & more

How to Create Custom Functions in R

How to Create Custom Functions in R

R programming for beginners: Select, filter and fill functions within the tidyverse

R programming for beginners: Select, filter and fill functions within the tidyverse

Introduction To `if` Statements In R

Introduction To `if` Statements In R

A tutorial for writing functions in R (CC177)

A tutorial for writing functions in R (CC177)

Deep House Mix 2024 | Deep House, Vocal House, Nu Disco, Chillout Mix by Diamond #3

Deep House Mix 2024 | Deep House, Vocal House, Nu Disco, Chillout Mix by Diamond #3

Lubridate — как манипулировать данными даты и времени в R

Lubridate — как манипулировать данными даты и времени в R

4 часа Шопена для обучения, концентрации и релаксации

4 часа Шопена для обучения, концентрации и релаксации

How to write an if else block in R and how its different from ifelse and if_else (CC175)

How to write an if else block in R and how its different from ifelse and if_else (CC175)

French Paris Chanson🎼Un Voyage Romantique Entre Mélodies Douces et Émotions Sous le Ciel de Paris 🇫🇷

French Paris Chanson🎼Un Voyage Romantique Entre Mélodies Douces et Émotions Sous le Ciel de Paris 🇫🇷

use ifelse() function in R to create dummy variables and categorical variables

use ifelse() function in R to create dummy variables and categorical variables

Tutorial - While Loops in R

Tutorial - While Loops in R

Playlist,,Deep House,Music Played in Louis Vuitton Stores

Playlist,,Deep House,Music Played in Louis Vuitton Stores

Handling NA in R | is.na, na.omit & na.rm Functions for Missing Values

Handling NA in R | is.na, na.omit & na.rm Functions for Missing Values

© 2025 ycliper. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: [email protected]