samedi 7 octobre 2017

why nested If statement doesn't return data frame r?

the nested if statement in this code is working very fine

x<-4
if(x==4){
  t<-x+1
  if(t==5){
   t+2
 }
}
[1] 7

but when i try the same code on data frame there is no results.

mydata_one<-data.frame(words= c("hello", "everyone"))
mydata_two<-data.frame(words= c("my"   , "name"    ))
if(length(mydata_one$word)==2){
  big_data<- rbind(mydata_one,mydata_two)
  if(length(big_data)>3){
    big_data[1:3,1]
   }
}

The expected value i am looking for:

[1] hello    everyone my

Aucun commentaire:

Enregistrer un commentaire