powered by
This function plots a scatterplot (scatter) on a given data frame, and adds a fit-line to the data.
scatter(df, var1, var2, lab = FALSE)
data frame to read in.
the dependent/outcome variable, \(Y\).
the independent/predictor variable, \(X\).
logical (default set to FALSE). When set to lab = TRUE, will add Pearson's correlation coefficient (\(r\)) value to the plot.
FALSE
lab = TRUE
data <- mtcars scatter(data,mpg,wt)
Run the code above in your browser using DataLab