![]() Simple.fit = lm(Sales~Spend, data=dataset) We’ll use Sales~Spend, data=dataset and we’ll call the resulting linear model “fit”. The lm function really just needs a formula (Y~X) and then a data source. ![]() The predictor (or independent) variable for our linear regression will be Spend (notice the capitalized S) and the dependent variable (the one we’re trying to predict) will be Sales (again, capital S). ![]() Simple (One Variable) and Multiple Linear Regression Using lm() #Use getwd() to see what your current directory is.ĭataset = read.csv("data-marketing-budget-12mo.csv", header=T,ĬolClasses = c("numeric", "numeric", "numeric")) #change your working directory to wherever you saved the csv. #You may need to use the setwd(directory-name) command to Assuming you’ve downloaded the CSV, we’ll read the data in to R and call it the dataset variable
0 Comments
Leave a Reply. |