if else语句

if else语句使用格式

1.
if (test) {
statement
}

2.
if (test) {
statement
} else {
statement
}

3.
if ( test) {
statement
} else if ( test) {
statement
} else if ( test) {
statement
} else {
statement
}
species=sample(c("human","mouse","rat"),1)
species
if(species=="human"){
  Annotated_data="org.Hs.eg.db"
  Abbreviation="hsa"
  print("human information")
}else if(species=="mouse"){
  Annotated_data="org.Mm.eg.db"
  Abbreviation="mmu"
  print("mouse information")
}else if(species=="rat"){
  Annotated_data="org.Rn.eg.db"
  Abbreviation="rno"
  print("rat information")
}else{
  print("end up")
}

你可能感兴趣的:(if else语句)