Variable assignment in R Question 3
R Programming Language Variable in R Language (Article) Variable in R Language (Program)
762Program:
# Assign a value to the variables my_apples and my_oranges my_apples <- 5 my_oranges <- 6 # Add these two variables together my_apples + my_oranges # Create the variable my_fruit my_fruit <- my_apples + my_oranges
Output:
> # Assign a value to the variables my_apples and my_oranges > my_apples <- 5 > my_oranges <- 6 > > # Add these two variables together > my_apples + my_oranges [1] 11 > > # Create the variable my_fruit > my_fruit <- my_apples + my_oranges > # Assign a value to the variables my_apples and my_oranges > my_apples <- 5 > my_oranges <- 6 > > # Add these two variables together > my_apples + my_oranges [1] 11 > > # Create the variable my_fruit > my_fruit <- my_apples + my_oranges > > # see result > my_fruit [1] 11
Explanation:
- Assign to
my_orangesthe value 6. - Add the variables
my_applesandmy_orangesand have R simply print the result. - Assign the result of adding
my_applesandmy_orangesto a new variablemy_fruit.
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.