dimanche 8 août 2021

Why do R if statments have to be in this format? [duplicate]

beginner to R and programming in general. Currently taking a beginner's course and was just wondering why an if statment had to be in this format:

if (nrow(recent_grads) > 1000) { 
    data_size <- "Large" 
    } else {
        data_size <- "Small"
    }

where the { and } characters have to be on seperate lines, as opposed to something more simple such as:

if (nrow(recent_grads) > 1000) { data_size <- "Large" }
  else {data_size <- "Small”}

Thanks for the help in advance.

Aucun commentaire:

Enregistrer un commentaire