Search
 
SCRIPT & CODE EXAMPLE
 

R

switch in r

# Following is val1 simple R program  
# to demonstrate syntax of switch.
  
# Mathematical calculation
  
val1 = 6  
val2 = 7
val3 = "s"  
result = switch(  
    val3,  
    "a"= cat("Addition =", val1 + val2),  
    "d"= cat("Subtraction =", val1 - val2),  
    "r"= cat("Division = ", val1 / val2),  
    "s"= cat("Multiplication =", val1 * val2),
    "m"= cat("Modulus =", val1 %% val2),
    "p"= cat("Power =", val1 ^ val2)
)  
    
print(result)
Comment

PREVIOUS NEXT
Code Example
R :: how to change the index of a dataframe in r 
R :: if not NA in r 
R :: correlation matrix in r 
R :: skewness in r 
R :: how to read in a text file in r 
R :: operators R 
R :: r count distinct dplyr 
R :: r append to vector 
R :: R dplyr select 
R :: r function syntax 
R :: rnorm in r 
R :: r string split 
R :: extract coefficients from lm in r 
R :: how to convert categorical data to numerical data in r 
R :: select a value in a data frame R 
R :: unset par mar 
R :: R excel 
R :: r read.csv tab delimited 
R :: dplyr to vector 
R :: R test if variable is NA 
R :: sumif in r 
R :: mean of a row dataframe in r 
Rust :: rust field is never read remove warning 
Rust :: how to concatenate two &str in rust 
Rust :: rust string to f64 
Rust :: const generics in rust 
Rust :: check if an item is in vec in rust 
Rust :: get function name rust 
Rust :: set interval Rust 
Rust :: rust-analyzer tab space 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =