Rscript -e 'df <- read.csv("data.csv"); print(summary(lm(salary ~ age, data = df))$coefficients)'

Category: Data Science & Analysis

Rscript -e 'df <- read.csv("data.csv"); print(summary(lm(salary ~ age, data = df))$coefficients)'

Fit a linear model of salary on age

The lm() function fits a linear regression, here salary modeled as a function of age, and summary() extracts its statistics. The dollar sign coefficients selection prints just the intercept and slope with their standard errors, p-values, and significance stars. This is the command-line entry point to statistical modeling in R. The tilde separates the outcome from the predictors.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.