Selection by comparison in R another way
R Programming Language / Vector in R Language
360Program:
# Poker and roulette winnings from Monday to Friday: poker_vector <- c(140, -50, 20, -120, 240) roulette_vector <- c(-24, -50, 100, -350, 10) days_vector <- c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday") names(poker_vector) <- days_vector names(roulette_vector) <- days_vector # Which days did you make money on poker? selection_vector <- poker_vector > 0 # Select from poker_vector these days poker_winning_days <- poker_vector[selection_vector] # See result poker_winning_days
Output:
> # See result > poker_winning_days Monday Wednesday Friday 140 20 240
Explanation:
# Select from poker_vector these days
poker_winning_days <- poker_vector[selection_vector]
# See result
poker_winning_days
This Particular section is dedicated to Programs only. If you want learn more about R Programming Language. Then you can visit below links to get more depth on this subject.
# C Tutorials
# JAVA Tutorials
# HTML Tutorials
# Computer Fundamental
# Data Structure
# DBMS Tutorials
SQL
# C# Language
# R Language
# PHP
# Python
# Vue JS