Common Functionalities in R
We have five types of objects in R to introduce for starters.
Types of objects :
It is a whole number like 1 , 52 ,896 ,25 etc. We create an integer object by join L with values as 1L , 2L , 10L etc. We can create integer object in this way-
It is used to find data type of object.
We can combine values in integer as –
 1 2
You can check Environment window . An object x created which shows int [1:2] 1 2 . Where int means integer data type.
When R did not find function it shows ERROR in Console window . As you can see in above snapshot.
We can also create integer object by following code :-
You can see in Environment window here:
It shows list of objects stored in Environment window. Here , it shows objects “a” and “b”
It shows structure of an object . Structure means data type and values of object.
It shows structure of object “x” .
We can also show structure of all objects stored in Environment window .
It shows structure of objects “a” and “x”.
It can remove object from Environment window .
You can check Environment window . It does not show “a” object .
We can remove all objects from window by using this command :
It shows Environment window is empty.
It contains both decimal and whole data . It includes values like 4 ,4.2 etc. It is default data type to store number in R.
We check data type of x by using following code :
We combine multiple values to store in an object as :
We check data type of “v” as –
To terminate the current R session . We can quit current session using following code :
It will open Quit R Session window as:
Save file :
You can save Script file as :
You can click on Save As…
It will open this window to save file .
To save file as “Day 1 R.R” . Enter File name as:-
File name – Day 1 R.R
Then click on Save to save file.
A character object is used to represent string values in R. A character object created by enter values in quotes(”) or double quotes(“”) .
You can run following code to create character object :
You can also create character object of number as –
It stores value in TRUE and FALSE.
We can create logical data type by using following code :
We also checked class of object “s” .
We can combine multiple values also. In below code , T represents TRUE and F represents FALSE
It is a combination of real and imaginary value . It is in the form of x+iy. Where “x” and “y” are real numbers and “i” shows imaginary number. You can create complex number by following code :-
When we divide 1 by 0 . Then , it represent infinity value.
NaN means Not A Number . The following example represent the same –