今天用wine数据集作为例子研究回归分析。首先导入和查看数据集,数据集已上传到附件链接可自行下载:
# 2. Regression Analysis
##############################
# First, download the data from Canvas and save it to your working directory where you store the data.
# Read data in csv format.
setwd('D:/rstudio') #设置工作区,自行调整
wine <- read.csv('wine.csv')
# Let's take a look at the variable names.
names(wine)
# The variables that will be used include:
# Year: Vintage year
# Price: Price of the wine (dependent variable)
# WinterRain: Precipitation in Winter
# AGST: Average Temperature
# HarvestRain: Harvester Precipitation
# Age: Aging Period
# FrancePop: France Population
str(wine)
summary(wine)