2020.4.09晚

Exercise in Chapter2 of ISL.

1.将导入数据的第一列固定为rownamesfix()快速编辑。(数据集名称为college)

rownames(college) <- college[, 1]
college <- college[, -1]

2.用pairs()创建散点图矩阵

pairs(college[, c(1:10)])
# create a scatter matrix using the first to tenth columns in data set.

3.使用plot()时,如果x-axis是定性变量,图会自动转换为boxplot
4.对数据集增加新的变量,并且根据已有变量的关系赋值。

Elite <- rep ("NO", nrow(college))  
#create a new vector all in logistic "NO", length equals the row length of college.

Elite[college $ Toptenperc >50] <- "YES".
#if the variable Toptenperc > 50 ,then coded as "YES".

Elite <- as.factor(Elite)
#transfer to factor.

college <- data.frame(college, Elite)
#merge Elite into college.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值