R语言中怎么定义只有0和1的向量

如题所述

vec<-rbinom(7,1,0.5)
或者,
vec<-sample(c(0,1),7,replace=T)
温馨提示:答案为网友推荐,仅供参考
相似回答