练习2-2: 向量生成
1.将两种不同类型的数据用c()组合在一起,看输出结果
> c(1,2,3"gene")
Error: unexpected string constant in "c(1,2,3"gene""
2.生成1到30之间所有4的倍数,答案是
> seq(from=4,to=28,by=4)
[1] 4 8 12 16 20 24 28
3.生成sample4,sample8,sample12…sample28
> paste0(rep("sample",time=7),seq(from=4,to=28,by=4))
[1] "sample4" "sample8" "sample12" "sample16"
[5] "sample20" "sample24" "sample28"
#第二种方法
> y = seq(from=4,to=28,by=4)
> x = rep("sample",length(y))
> paste0(x,y)
[1] "sample4" "sample8" "sample12" "sample16"
[5] "sample20" "sample24" "sample28"