What is a Variable and how to assign value to a variable?

Description

To identify valid variable name,assigning values,finding its data type and deleting variable.

    • Variable is a data of any type that is to be processed

Rules for variables name :

    • Can have letters,dots,underscore
    • Can start with a dot (.) but dot (.) followed by number not valid
    • Shouldn’t start with number
    • Shouldn’t start with an underscore

Assigning value to variable :

  • Equal operator (=) x=5
  • Leftward operator (<-) y<-10
  • Rightward operator (->) 15->z
  • To find the class type of the variable – class(variablename)
  • To find currently avaialble variables – ls()
  • To list variables starting with particular pattern – ls(pattern=”var”)
  • Variables starting with dot (.) are hidden,they can be listed using – ls.(all.name=TRUE)
  • Deleting single variable – rm()
  • Deleting All variables – em(list=ls())

#R Programming
if(FALSE)
{
“This is a multiline comment line.
This is an example for explaining vector objects”
}
var_a=TRUE #Equalto assignment opr
var_bc #rightward assignment opr
d=3+2i
var_e<-“Hello!” charToRaw(e)->f
print(class(var_a))
print(class(var_b))
print(class(c))
print(class(d))
print(class(var_e))
print(class(f))
print(ls())
print(ls(pattern = “var”))
print(d)
rm(d)
print(d)

Leave Comment

Your email address will not be published. Required fields are marked *

clear formSubmit