0% found this document useful (0 votes)
30 views4 pages

Installation of R and R Studio With The Sample Examples

The document demonstrates basic operations in R like assigning variables of different data types, performing arithmetic, logical, and comparison operations, creating and manipulating vectors and matrices. It assigns variables, performs print operations, arithmetic calculations, logical operations, creates and prints vectors and matrices, extracts elements from vectors and matrices.

Uploaded by

roshan.csds
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views4 pages

Installation of R and R Studio With The Sample Examples

The document demonstrates basic operations in R like assigning variables of different data types, performing arithmetic, logical, and comparison operations, creating and manipulating vectors and matrices. It assigns variables, performs print operations, arithmetic calculations, logical operations, creates and prints vectors and matrices, extracts elements from vectors and matrices.

Uploaded by

roshan.csds
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Installation of R and R studio with the sample examples

double_var<-3.14
integer_var<-42
logical_var<-TRUE
complex_var<-1+2i
character_var<-"Hello,R!"
print(double_var)
print(integer_var)
print(logical_var)
print(complex_var)
print(character_var)

result_addition<-double_var+integer_var
result_multiplication<-double_var*integer_var
result_subtraction<-integer_var-double_var
result_division<-integer_var/double_var
print(result_addition)
cat("Multiplication",result_multiplication,"\n")
print(result_subtraction)
print(result_division)

result_logical_and<-logical_var&&FALSE
result_logical_or<-logical_var||FALSE
result_logical_not<-!logical_var
print(result_logical_and)
print(result_logical_or)
print(result_logical_not)

sequence_vector<-seq(1,10,2)
created_vector<-c(5,10,15,20,25)
print(sequence_vector)
print(created_vector)
matrix_a<-matrix(1:6,nrow=2,ncol=3)
print("Matrix A : ")
print(matrix_a)
print("\n")

vector_x<-c(2,4,6)
vector_y<-c(8,10,12)
matrix_b<-cbind(vector_x,vector_y)
matrix_c<-rbind(vector_x,vector_y)

print("Matrix B : ")
print(matrix_b)
print("Matrix C : ")
print(matrix_c)
print("\n")

element_vector<-created_vector[3]
element_matrix<-matrix_a[1,2]
print(element_vector)
print(element_matrix)

Output:

[1] 3.14
[1] 42
[1] TRUE
[1] 1+2i
[1] "Hello,R!"
[1] 45.14
Multiplication 131.88
[1] 38.86
[1] 13.3758
[1] FALSE
[1] TRUE
[1] FALSE
[1] 1 3 5 7 9
[1] 5 10 15 20 25
[1] "Matrix A : "
[,1] [,2] [,3]
[1,] 1 3 5
[2,] 2 4 6
[1] "\n"
[1] "Matrix B : "
vector_x vector_y
[1,] 2 8
[2,] 4 10
[3,] 6 12
[1] "Matrix C : "
[,1] [,2] [,3]
vector_x 2 4 6
vector_y 8 10 12
[1] "\n"
[1] 15
[1] 3
> source("~/priyankarb.r")
[1] 3.14
[1] 42
[1] TRUE
[1] 1+2i
[1] "Hello,R!"
[1] 45.14
Multiplication 131.88
[1] 38.86
[1] 13.3758
[1] FALSE
[1] TRUE
[1] FALSE
[1] 1 3 5 7 9
[1] 5 10 15 20 25
[1] "Matrix A : "
[,1] [,2] [,3]
[1,] 1 3 5
[2,] 2 4 6
[1] "\n"
[1] "Matrix B : "
vector_x vector_y
[1,] 2 8
[2,] 4 10
[3,] 6 12
[1] "Matrix C : "
[,1] [,2] [,3]
vector_x 2 4 6
vector_y 8 10 12
[1] "\n"
[1] 15
[1] 3

You might also like