Learn R Programming

vannstats (version 1.5.1.8)

scatter: Simplified Scatterplot

Description

This function plots a scatterplot (scatter) on a given data frame, and adds a fit-line to the data.

Usage

scatter(df, var1, var2, lab = FALSE)

Arguments

df

data frame to read in.

var1

the dependent/outcome variable, \(Y\).

var2

the independent/predictor variable, \(X\).

lab

logical (default set to FALSE). When set to lab = TRUE, will add Pearson's correlation coefficient (\(r\)) value to the plot.

Examples

Run this code
data <- mtcars

scatter(data,mpg,wt)

Run the code above in your browser using DataLab