Rotate your phone or change to desktop for better experience

Rotate your phone or change to desktop for better experience

9. Write a R program for any visual representation of an object with creating graphs using graphic functions: Plot(),Hist(),Linechart(),Pie(),Boxplot(),Scatterplots(). || R

# Create sample data 

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

y <- c(3, 5, 7, 2, 8) 

# Create a new graphics device (window) 

dev.new() 

# Create a plot 

plot(x, y, type = "o", main = "Line Chart", xlab = "X

axis", ylab = "Y-axis", col = "blue") 

# Create a new graphics device 

dev.new() 

# Create a histogram 

hist(x, main = "Histogram", xlab = "Value", ylab = 

"Frequency", col = "lightgreen") 

# Create a new graphics device 

dev.new() 

# Create a line chart 

lines(x, y, type = "o", col = "red") 

title(main = "Line Chart", xlab = "X-axis", ylab = "Y

axis") 

# Create a new graphics device

dev.new() 

# Create a pie chart 

pie(x, labels = c("A", "B", "C", "D", "E"), main = "Pie 

Chart") 

# Create a new graphics device 

dev.new() 

# Create a boxplot 

boxplot(x, main = "Boxplot", ylab = "Values", col = 

"orange") 

# Create a new graphics device 

dev.new() 

# Create a scatterplot 

plot(x, y, main = "Scatterplot", xlab = "X-axis", ylab = 

"Y-axis", col = "green", pch = 19)

Post a Comment

0 Comments