Category Archives for "R Programming"

Jan 13

cbind R example

By ganpati | R Programming

11cbind_img

cbind function in R

What it does?
It adds the columns of the second data frame to the columns of the first data frame provided both data frames have same number of rows
Syntax:
print (data frame1, data frame2)
Example:
We have two dataframes samp1 and samp2 as below:

samp1

col1 col2 col3

1 1 6 11
2 2 7 12
3 3 8 13
4 4 9 14
5 5 10 15
> samp2

col1 col2 col3

1 16 21 26
2 17 22 27
3 18 23 28
4 19 24 29
5 20 25 30
cbind(samp1, samp2)

col1 col2 col3 col1 col2 col3

1 1 6 11 16 21 26
2 2 7 12 17 22 27
3 3 8 13 18 23 28
4 4 9 14 19 24 29
5 5 10 15 20 25 30

Jan 13

R print Example

By ganpati | R Programming

10print_img

print function in R

What it does?
It shows on the screen the value of the arguments passed to it
Syntax:
print (any variable)
Example:
x<- 2+2

print (x)

[1] 4

Jan 13

R Sequence Example

By ganpati | R Programming

9seq_img

sequence function in R

What it does?
It creates a sequence of numbers based on a given start point, end
point and interval
Syntax:
seq (starting number, ending number, increment)
Example:
seq (1,10,2)
[1] 1 3 5 7 9