# Assign a value to the variables my_apples and my_oranges my_apples <- 5 my_oranges = 6 # Add these two variables together and print the result my_oranges + my_apples # Create the variable my_fruit my_fruit = my_oranges + my_apples # Clear the entire workspace rm(list = ls()) # List the contents of your workspace ls() # Create the variable horses horses <-3 # Create the variable dogs dogs <-7 # Create the variable animals animals <- horses + dogs # Inspect the contents of the workspace again ls() # Remove dogs from the workspace rm(dogs) # Inspect the objects in your workspace once more ls() # Create variables var1, var2 and var3 var1 <- TRUE var2 <- 0.3 var3 <- "i" # Convert var1 to a character: var1_char var1_char <- as.character(var1) # See whether var1_char is a character is.character(var1_char) # Convert var2 to a logical: var2_log var2_log <- as.logical(var2) # Inspect the class of var2_log class(var2_log) # Coerce var3 to a numeric: var3_num var3_num <- as.numeric("i") VECTORS numeric_vector <- c(1, 10, 49) character_vector <- c("a", "b", "c") # Create boolean_vector boolean_vector <-c(TRUE,FALSE,TRUE) # Poker winnings from Monday to Friday poker_vector <- c(140, -50, 20, -120, 240) # Roulette winnings from Monday to Friday: roulette_vector roulette_vector <-c(-24,-50,100,-350,10) # Poker winnings from Monday to Friday poker_vector <- c(140, -50, 20, -120, 240) # Roulette winnings from Monday to Friday roulette_vector <- c(-24, -50, 100, -350, 10) # Add names to both poker_vector and roulette_vector names(poker_vector) <-c("Monday","Tuesday","Wednesday","Thursday","Friday") names(roulette_vector) <-c("Monday","Tuesday","Wednesday","Thursday","Friday") # Poker winnings from Monday to Friday poker_vector <- c(140, -50, 20, -120, 240) # Roulette winnings from Monday to Friday roulette_vector <- c(-24, -50, 100, -350, 10) # Create the variable days_vector days_vector <-c("Monday","Tuesday","Wednesday","Thursday","Friday") # Assign the names of the day to roulette_vector and poker_vector names(poker_vector)<-days_vector names(roulette_vector)<-days_vector