R Programming Language
R Programming Language
R Programming Language:
R programming is written by Robert Gentleman and Ross Ihaka is a language for statistical computing
and graphics.
R programming is commonly used to solve Statistics, Time series, Classification, and other Data science
tasks.
You can become a Data Scientist, Statistician, Data Analyst, R programmer, Business Analyst.
R is an open-source programming language used for statistical computing. It is one of the most popular
programming languages today. R was inspired by S+, it is similar to the S programming language.
Features in R:
Variables in R:
Variables are used to store data with the named locations that your programs can manipulate.
R is case sensitive.
Valid variables
Data Types in R:
Numeric: 10.5,7,845
Integer: 3L,40L, 4L
Complex: 3+2i
Logical Operators:
And - & = Return TRUE if both the conditions are true, else return FALSE.
[1] FALSE
[1] TRUE
Not -! = Takes each element of the vector and gives the opposite logical value.
[1] TRUE
Athematic operators:
Addition
Subtraction
Multiplication
Division
Remainder/Modulus
Exponent
3
Order of operators:
Parenthesis ()
Exponents (^)
Rational/Logical operators:
greater than
less than
less than/equal to
equal to
not equal
Print Formatting:
>print(x)
[1] 10
R uses the paste () and paste0() function to format strings and variables together for printing in a few
different ways.
[1] “helloworld”
[1] “welcome”
4
#Empty vectors can be created with vector () function, A vector can contain objects of same type/class.
Vectors:
Example:
v1<- c (1,2,3,4,5)
#numbers such as 1 or 2etc (Thought at integer and represented as numeric objects behind the scenes
such as 1.00 or 2.00)
1/Inf
List:
List: A list is a generic vector that can contain object of different types.
Example:
print(list_1)
5
Output:
> list_1
$x
[1] 10 20 30
Sy
$z