Help on topic 'plot' was found in the following packages:
Package Library
graphics /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library
base /Library/Frameworks/R.framework/Resources/library
Using the first match ...
plot(x =CO2$uptake, y =CO2$conc, xlab ="CO2 Uptake", ylab ="C02 Concentration", main ="Best Fit Line", sub ="", bg ="lightblue", # a vector of background colors (Graphical Parameters) col ="black", # the colors for lines and points (Graphical Parameters) cex =.9, # a numerical vector giving the amount by which plotting characters and symbols should be scaled relative to the default = 1 (Graphical Parameters) pch =21, # a vector of plotting characters or symbols (Graphical Parameters) {triangle, empty circle, filled circle, square,...} frame =TRUE# frame.plot - a logical indicating whether a box should be drawn around the plot.)?ablineabline(reg =lm(data =CO2, formula =conc~uptake), lwd =2, # line width, default = 1 col ="blue")
Intercept values are also the same (as expected) !!!
We will plot the data and best fit line below.
?plot
Help on topic 'plot' was found in the following packages:
Package Library
graphics /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library
base /Library/Frameworks/R.framework/Resources/library
Using the first match ...
plot(x =CO2$uptake, y =CO2$conc, xlab ="CO2 Uptake", ylim =c(0, 1000), xlim =c(0,50), ylab ="C02 Concentration", main ="Best Fit Line", sub ="", bg ="lightblue", # a vector of background colors (Graphical Parameters) col ="black", # the colors for lines and points (Graphical Parameters) cex =.9, # a numerical vector giving the amount by which plotting characters and symbols should be scaled relative to the default = 1 (Graphical Parameters) pch =21, # a vector of plotting characters or symbols (Graphical Parameters) {triangle, empty circle, filled circle, square,...} frame =TRUE# frame.plot - a logical indicating whether a box should be drawn around the plot.)?ablineabline(reg =lm(data =CO2, formula =conc~uptake), lwd =2, # line width, default = 1 col ="blue")
Caution
This formula works for simple linear regression, where you have one independent variable (X) and one dependent variable (Y). However, when you move to multivariate regression, which involves multiple independent variables, the formula for calculating the coefficients becomes more complex.