It seems fairly simple but using R I'm trying to generate a vector of numbers from -2 to 100 starting with even numbers from -2 to 50 then odd numbers from 45 to 69 followed by even numbers from 72 to 100
I've tried using ifelse functions as well as using !i%%2==0 but I haven't been able to create a single vector from this loop that has the change from even to odd then back
a<-c()
b<-a
d<-a
for(i in seq(-2,100,by=2)){
a<-c(a,i)
if(i>=76){
d<-c(d,i)
}
if(i>35){
b<-c(b,i+1)
}
if(i<40){
a<-c(i)
}
}
print(a)
print(b)
print(d)
vec<-c(b,d)
print(vec)
Aucun commentaire:
Enregistrer un commentaire