-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinear.R
More file actions
21 lines (17 loc) · 825 Bytes
/
linear.R
File metadata and controls
21 lines (17 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Load the dataset from a CSV file
dataset <- read.csv("C:\\Users\\aadhi\\Desktop\\R\\data-marketing-budget-12mo.csv")
# Display the first 5 rows of the dataset
head(dataset, 5)
# Display the number of rows and columns
print(paste("Number of rows:",nrow(dataset)))
print(paste("Number of cols:",ncol(dataset)))
# Simple Linear Regression
# Fit a linear model where Sales is the response variable and Spend is the predictor
simple.fit = lm(Sales ~ Spend, data = dataset)
# Display summary statistics of the simple linear regression model
summary(simple.fit)
# Multiple Linear Regression
# Fit a linear model where Sales is the response variable and Spend and Month are predictors
multi.fit = lm(Sales ~ Spend + Month, data = dataset)
# Display summary statistics of the multiple linear regression model
summary(multi.fit)