dimanche 1 septembre 2019

argument is of zero length

In R language When I wanted to run this code, it tells me "Read 0 items Error in if (input == random) { : argument is of length zero" I do not know why

random <- sample(1:20,1)
for(i in 1:6){
  input <- scan()
  if(input==random){
    print(paste0("Congratulations, you guessed correctly in ",i, " tries"))
    break
  }else if(input<random){
    print("Too low")
  }else{
    print("Too high")
  }
}

Aucun commentaire:

Enregistrer un commentaire