mercredi 2 octobre 2019

how to save a variable from for loop

I want to classify my variables and save the output, but the "test" is null. how can I fix the problem?

x<-sample(10)
npz<-function(x)
{
  for(x in x)
if (x < 0) {
  print("Negative number")
} else if (x > 0) {
  print("Positive number")
} else
  print("Zero")
}
test<-npz(x)
test

Aucun commentaire:

Enregistrer un commentaire