Using plot() function we can create a scatterplot.
We need two points or data vectors it will generate a scatter plot.
# Create sample data
x <- 1:10
y <- 2 * x + 3 + rnorm(10)
# Create a scatter plot
plot(x, y, main = "Scatter Plot", xlab = "X-axis", ylab = "Y-axis", pch = 16, col = "blue")
Using abline() function we can create a common line for tht scatter plot.
# Create sample data
x <- 1:10
y <- 2 * x + 3 + rnorm(10)
# Create a scatter plot
plot(x, y, main = "Scatter Plot with Line", xlab = "X-axis", ylab = "Y-axis", pch = 16, col = "blue")
# Add a line to the plot using abline()
abline(a = 3, b = 2, col = "red", lty = 2)
The Concepts and codes you leart practice in Compilers till you are confident of doing on your own. A Various methods of examples, concepts, codes availble in our websites. Don't know where to start Down some code examples are given for this page topic use the code and compiler.