Ex 1
Ex 1
Aim
To determine various basic operations in R, such as creating, manipulating vectors, matrices and
data frames, performing basic statistical calculations, and reading data from a csv file.
Procedure
Step 1: Start
Step 2: To create sequence use function like seq() and c() to create vector
Step 3: Perform arithmetic operations and check the mode of vectors
Step 4: To reshape vectors into matrices use dim() to convert vectors into matrices
Step 5: For statistical calculation, calculate mean and median of numeric vectors
Step 6: Extend vectors by appending elements to exisiting vectors
Step 7: For creating data frame, combine vectors info data frame using data frame
Step 8: To read csv file by using read.(csv) to import data from csv
Step 9: Stop
5. Importing ggplot2
# Importing ggplot2
library(ggplot2)
# Creating a data frame
data_frame1 = data.frame(x= c(2,4,3,1),y = c(3,1,6,8))
# Plotting the data
ggplot(data_frame1,aes(x = x , y =y)) + geom_point()+ theme(panel.background = element_rect(fill
= 'green', color = 'blue'))
Result
Thus the above code is executed successfully and also created, manipulated vectors
matrices, data frames from csv files.