Wednesday, January 31, 2024

Program 7- Graphs in R- Line graph, Box plot , bar plot and scatter plot in R language R Programming Lab - Bsc CS DA and BSC ML And AI -Bharathiar University -

 

B.Sc Computer Science  

R Programming - Lab  

Bharathiar University 

Program 7

Graphs in R

Program 6- Write a R program to demonstrate various types of graphs

SOURCE CODE:


# Create sample data

x <- c(1, 2, 3, 4, 5)

y <- c(2, 4, 6, 8, 10)


par(mfrow = c(2, 2))


# Plot a basic line graph

pts <- c(2,3,4,6,8)

 plot(pts, type = "o", col = "blue", lwd = 2, main = "Simple Line Graph", xlab = "X-axis", ylab = "Y-axis")



# Add points to the graph

points(pts, col = "red", pch = 16)



barplot(c(3, 5, 2, 7, 4), names.arg = c("A", "B", "C", "D", "E"), col = "orange", main = "Bar Plot", xlab = "Categories", ylab = "Values")

plot(x, y, col = "green", pch = 18, main = "Scatter Plot", xlab = "X-axis", ylab = "Y-axis")


boxplot(x, col = "blue", names = "X", main = "Box Plot", xlab = "Variables", ylab = "Values")


Sample Output:



No comments:

Post a Comment

Program 12 BCA Madras University BCA Object Oriented Programming using C++ Practical Madras University Program 12 Implement a telephone directory using files

  BCA Object Oriented Programming using C++ Practical Madras University  Program 12  Implement a telephone directory using files SOURCE CODE...