Beruflich Dokumente
Kultur Dokumente
Variable
declaration with
<- operator
Explicit printing
by print() function
Auto-printing
Comments with
##
Character - string or any alphanumeric characters are accepted e.g. Hello World
Numeric any numeric object or double precession real number e.g. 10.55 , 4.99 etc.
Complex numbers any complex numbers e.g. 2+4i , 2-4i etc.
Integer any integer e.g. 1,2,3,5 etc. Have to declare with a L suffix e.g. 1L
Logical - this can be either TRUE or FALSE
data types
Vector() can create an empty vector
R also contains two special numbers
Inf : Infinity e.g. 1/0 gives us INF while 1/INF gives 0
NaN : Not a number
NA
9
Attributes of the
matrix, the number of
rows and number of
column
10
11
After conversion
the resultant can be
stored in a separate
variable
The conversion
does not affect the
data type of the
variable y
12
Mixing more than one objects in a vector results in a vector with a data type of least common
13
List is just like a vector in which each element can be of different type
14
15
Transforms x into a
matrix of 2 rows and
5 columns.
16
17
Each level is
associated with a
integer value
18
Factor creation :
19
is.na() : test for a NA value. It returns TRUE logical value for the NA and NaN values
is.nan() : test if a value is not a number. It returns TRUE logical value for the NaN value
20
21
22
23
24
Make a rough estimate of the memory needed and check the RAM requirements
Set comment.char = in case there are no comments
Set colClasses so that R dont have determine the data types in runtime
26
27
File structure
28
File structure
29
w = write mode
rb , wb , ab = read, write and append on binary file
30
if (<logical_condition>){
## Executable statement 1
}
else if (<logical_condition>){
## Executable statement 2
}
else{
## Executable statement 3
}
31
32
33
Used when a set of statements are needed to repeat a fixed number of times
Syntax:
Type1:
Type 2 :
for(<range>){
for(<var> in seq_along(<var>)){
## Executable statement
## Executable statement
Type 3 :
Type 4 :
for(<var> in <var>){
## Executable statement
## Executable statement
}
}
34
35
36
37
Here is an
example of nested
for loop
This loop loops
around all the
elements of matrix
x and prints them
38
while(<logical_condition>){
## Executable statement
}
39
40
repeat{
## Executable statement
}
41
42
43
Syntax:
44
Example:
Function name is x
45
Syntax:
Example:
47