switch Statement in R (2 Examples) | How to Use the switch() Function | Select Alternative in List

preview_player
Показать описание
R code of this video:

switch(2, "first", "second", "third") # Apply switch function

my_input <- c(3, 1, 2, 4, 1) # Create input vector

for(i in 1:length(my_input)) { # for-Loop with switch function
my_output <- switch(my_input[i],
"first", "second", "third")
print(my_output)
}

Follow me on Social Media:
Рекомендации по теме
Комментарии
Автор

Thank you. I did not know switch function existed.

dangunwangum
Автор

April Fools Day Date: April 1, 2021 @11:51 pm yesterday just got some updates coming from our professor in our Major Subject was posted in Google Classroom said that we have new Assignments to do and to be passed on Monday April 5, 2021 when i check the problem it says we need to create a program or script that compute the Pythagorean theorem and apply if and switch statement in a separate script which provides user input and etc i decided to search in youtube to get some ideas and finally youtube brings me here on this Channel heheh really helpful but still stuggling but I'm trying to be that slow learner by the way thank you for providing the informations needed to every students especially those slow learner like me God Bless :)hope oyu create more about R Studio

charliebraganza
visit shbcf.ru