Variable assignment in R

R Programming Language / Variable in R Language

246

Program:

# Assign the value 42 to x
x <- 42

# Print out the value of the variable x
x

Output:

> # Assign the value 42 to x
> x <- 42
> 
> # Print out the value of the variable x
> x
[1] 42

Explanation:

A basic concept in (statistical) programming is called a variable.

A variable allows you to store a value (e.g. 4) or an object (e.g. a function description) in R. You can then later use this variable's name to easily access the value or the object that is stored within this variable.

You can assign a value 4 to a variable my_var with the command

my_var <- 4

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.