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

  Рет қаралды 4,201

R Programming 101

R Programming 101

Күн бұрын

Пікірлер: 13
@RProgramming101
@RProgramming101 3 ай бұрын
Get my FREE cheat sheets for R programming and statistics (including transcripts of these lessons) here: www.learnmore365.com/pages/membership-r-programming-data-visualization-and-research-methods
@EmersonScheidegger
@EmersonScheidegger 2 ай бұрын
Your content submission is amazing!!! please, keep going!
@RProgramming101
@RProgramming101 Ай бұрын
wow - thanks for the lovely comment
@2012Opus
@2012Opus 4 ай бұрын
Thank you! The only confusing this the final argument: TRUE ~. This is a bit counterintuitive.....
@neytchi8709
@neytchi8709 4 ай бұрын
Your content submission is rocket!
@RProgramming101
@RProgramming101 4 ай бұрын
Thanks.. :)
@RUJedi
@RUJedi 4 ай бұрын
Fantastic video as always. However, why use if_else() from dplyr when there is ifelse() from base R? Sure, if_else() has an extra argument option for processing missing values, that could still be handled with the base R version without much effort too. Sometimes I think the Tidyverse over-complicates code by offering more code choices when the base R version is equivalent or nearly as good.
@maizeblue699
@maizeblue699 3 ай бұрын
I've had issues with if_else() being more restrictive with outputs and have switched to ifelse(). Let's say you want to output either a character or a number depending on your condition. For example, I want to convert all my 0 values (considering them as below LOQ) in variable_1 to "NA" and leave the rest as numeric values so I ca then use "na.exclude()": mutate(variable_2 = if_else(variable_1 == 0, "NA", variable_2) will give me an error. This same code works if I use "ifelse()" instead. I was initially using embedded if else statements and eventually realized case_when is a lot more compact.
@ampauls
@ampauls 4 ай бұрын
Fantastic. I'm curious then, if you like the table you've made, and want to use it in a paper or presentation, how do you export that? Is it simply copy and paste, or is there a command we can use to export the table?
@RProgramming101
@RProgramming101 4 ай бұрын
oh there is a way of getting the tables out - I'll do a video all about it soon (hard to get into the details here in the comments)
@ampauls
@ampauls 4 ай бұрын
@@RProgramming101 fantastic. Appreciate it!
@jackymo820
@jackymo820 4 ай бұрын
In the case_when example, both FALSE actions (when the 2 conditions were not met) were the same (putting original hair colour) what if the FALSE action of the 2 conditions is different?
@NattyGism
@NattyGism 4 ай бұрын
🎉 always love every post and always looking forward to more. Thank Greg# R_ Super hero 🦸🏽‍♂️ Very helpful.
Create tables in R with gtExtras  (more tips and tricks)
8:43
R Programming 101
Рет қаралды 3,7 М.
A tutorial for writing functions in R (CC177)
14:37
Riffomonas Project
Рет қаралды 16 М.
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 45 МЛН
Каха и дочка
00:28
К-Media
Рет қаралды 1,6 МЛН
Cat mode and a glass of water #family #humor #fun
00:22
Kotiki_Z
Рет қаралды 10 МЛН
小路飞和小丑也太帅了#家庭#搞笑 #funny #小丑 #cosplay
00:13
家庭搞笑日记
Рет қаралды 17 МЛН
Say Goodbye to IF Statements in Excel with SWITCH
7:45
Teacher's Tech
Рет қаралды 589 М.
Manipulate your data.   Data wrangling.   R programmning for beginners.
29:59
R Programming 101
Рет қаралды 81 М.
A step-by-step guide to parameterized reporting in R using Quarto
20:16
R for the Rest of Us
Рет қаралды 3,6 М.
Write your own R functions
15:32
Equitable Equations
Рет қаралды 4 М.
Writing Your Own Functions in R: Introduction
12:45
weecology
Рет қаралды 48 М.
Quarto - tips and tricks
15:03
R Programming 101
Рет қаралды 7 М.
How to impute missing data using mice package in R programming
11:26
Rajendra Choure
Рет қаралды 7 М.
Lubridate - how to manipulate date and time data in R
18:05
R Programming 101
Рет қаралды 12 М.
Conditional Statements in R (If, Else If, and Else)
12:02
Becoming a Data Scientist
Рет қаралды 17 М.
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 45 МЛН