mardi 15 octobre 2019

For Loop and If in R Programming

I think I have a simple question, but I can not figure out how to do it. I just wanna plot all hist of an data input and check if all var are numerical.

plotting_histogram_data<-function(x) {
  for(i in seq_len((ncol(x)))) {
    if(is.numeric(x[,i])) { 
      hist(x[,i])
    }
    else{
      print("Variable is not of the Typ numeric!")
    }
    }
}

I know that the problem is the index.

Thank and have nice day.

Aucun commentaire:

Enregistrer un commentaire