1. Learn
  2. /
  3. Courses
  4. /
  5. Feature Engineering in R

Exercise

A tentative model

You are handed a data set with measures of the gravitational force between two bodies at different distances and are challenged to build a simple model to predict such force given a specific distance. Initially, you want to stick to simple linear regression. The data consist of 120 pairs of distance and force, and is loaded for you as newton.

Instructions

100 XP
  • Build a linear model for the newton data using the linear model from base R function and assign it to lr_force.
  • Create a new data frame df by binding the prediction values to the original newton data.
  • Generate a scatterplot of force versus distance using ggplot().
  • Add a regression line to the scatterplot with the fitted values.