任务一:列表操作
任务内容:
stu_id <- c(101,102,103,104,105)
stu_age <- c(20,21,20,21,22)
stu_class <- c("jr","jr","kj","kj","jr")
stu_perf <- c("excellent","average","good","poor","average")
stu1 <- list("学号"=stu_id,"年龄"=stu_age,"班级"=stu_class ,"成绩"=stu_perf)
生成列表后进行如下操作:
1.班级信息前面加“信息”二字
2.年龄的值加5
注意:一定是对列表的操作,不是对向量的操作
代码及运行结果:
> stu_id <- c(101,102,103,104,105)
> stu_age <- c(20,21,20,21,22)
> stu_class <- c("jr","jr","kj","kj","jr")
> stu_perf <- c("excellent","average","good","poor","average")
>
> stu1 <- list("学号"=stu_id,"年龄"=stu_age,"班级"=stu_class ,"成绩"=stu_perf)
> #生成列表后进行如下操作:
> #1.班级信息前面加“信息”二字
> #注意:一定是对列表的操作,不是对向量的操作
> stu1
$学号
[1] 101 102 103 104 105
$年龄
[1] 20 21 20