Open In App

Assigning values to variables in R programming – assign() Function

Last Updated : 10 May, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

In R programming, assign() method is used to assign the value to a variable in an environment.

Syntax : assign(variable, value)
Return : Return the variable having value assigned.

Example 1:




# Using assign() method
assign("gfg", 10)
  
print(gfg)


Output:

[1] 10

Example 2:




# Using assign() method
assign("gfg", 20.12345)
  
print(gfg)


Output:

[1] 20.12345

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads