Hola Gabriel,

Creo que he encontrado a "Wally" ("Waldo"). Realmente había varios
"Wally"... :-).


   1. En el "if" buscabas en la matriz por "AIMS" cuando este row.name() no
   existe el que existe en con "N": "AI*N*S". Bastó por tanto sustituir
   AIMS por AINS para corregir este error.
   2. Con esta sustitución también se arregló otro error que por el mismo
   motivo se producía más adelante en la función.
   3. Pero es que además había más errores:
      1. Al final de la función en "Data1" cuando creas el data.frame,
      había una variable "elmi1" que no está definida y esto también
provocaba un
      error.
      2. E igualmente al final de la función dices "print(ABI)" cuando
      debiera de decir "print(ABI*1*)", faltaba el "1". Este error provoca
      que como resultado salga el código de la función en vez del resultado.


Adjunto el código con todas estas correcciones.
Sobre la matriz de ejemplo que has incluido el resultado que se obtiene es:

PTUR-001
     133



#########################################

ABI <- function(x){
  MIBpa <- x
  turb1<-5*MIBpa[match("PTUR-001",row.names(MIBpa)),]

if(MIBpa[match("MGAS-001",row.names(MIBpa)),]==1||MIBpa[match("MGAS-002",row.names(MIBpa)),]==1){
    Coc2=3} else
{if(MIBpa[match("MGAS-001",row.names(MIBpa)),]==0&&MIBpa[match("MGAS-002",row.names(MIBpa)),]==0){
      Coc2=0}}
  Lym2<-3*MIBpa[match("MGAS-003",row.names(MIBpa)),]
  phys1<-3*MIBpa[match("MGAS-004",row.names(MIBpa)),]
  Cor2<-3*MIBpa[match("MBIV-001",row.names(MIBpa)),]
  Sph2<-3*MIBpa[match("MBIV-002",row.names(MIBpa)),]

if(MIBpa[match("NCLI-001",row.names(MIBpa)),]==1||MIBpa[match("NCLI-002",row.names(MIBpa)),]==1||MIBpa[match("NCLI-003",row.names(MIBpa)),]==1||MIBpa[match("NCLI-004",row.names(MIBpa)),]==1||

 MIBpa[match("NCLI-005",row.names(MIBpa)),]==1||MIBpa[match("NCLI-006",row.names(MIBpa)),]==1||MIBpa[match("NCLI-007",row.names(MIBpa)),]==1||MIBpa[match("NCLI-008",row.names(MIBpa)),]==1){
    Oli2=1} else
{if(MIBpa[match("NCLI-001",row.names(MIBpa)),]==0&&MIBpa[match("NCLI-002",row.names(MIBpa)),]==0&&MIBpa[match("NCLI-003",row.names(MIBpa)),]==0&&MIBpa[match("NCLI-004",row.names(MIBpa)),]==0&&

 MIBpa[match("NCLI-005",row.names(MIBpa)),]==0&&MIBpa[match("NCLI-006",row.names(MIBpa)),]==0&&MIBpa[match("NCLI-007",row.names(MIBpa)),]==0&&MIBpa[match("NCLI-008",row.names(MIBpa)),]==0){
      Oli2=0}}

if(MIBpa[match("NHIR-001",row.names(MIBpa)),]==1||MIBpa[match("NHIR-002",row.names(MIBpa)),]==1){
    Glo2=3} else
{if(MIBpa[match("NHIR-001",row.names(MIBpa)),]==0&&MIBpa[match("NHIR-002",row.names(MIBpa)),]==0){
      Glo2=0}}
  Dap2<-3*MIBpa[match("AMAL-001",row.names(MIBpa)),]

if(MIBpa[match("AMAL-002",row.names(MIBpa)),]==1||MIBpa[match("AMAL-003",row.names(MIBpa)),]==1){
    Hya2=6} else
{if(MIBpa[match("AMAL-002",row.names(MIBpa)),]==0&&MIBpa[match("AMAL-003",row.names(MIBpa)),]==0){
      Hya2=0}}
  Pal2<-6*MIBpa[match("AMAL-004",row.names(MIBpa)),]

if(MIBpa[match("AARA-001",row.names(MIBpa)),]==1||MIBpa[match("AARA-002",row.names(MIBpa)),]==1||MIBpa[match("AARA-003",row.names(MIBpa)),]==1||MIBpa[match("AARA-004",row.names(MIBpa)),]==1||

 MIBpa[match("AARA-005",row.names(MIBpa)),]==1||MIBpa[match("AARA-006",row.names(MIBpa)),]==1||MIBpa[match("AARA-007",row.names(MIBpa)),]==1||MIBpa[match("AARA-008",row.names(MIBpa)),]==1||

 MIBpa[match("AARA-009",row.names(MIBpa)),]==1||MIBpa[match("AARA-010",row.names(MIBpa)),]==1||MIBpa[match("AARA-011",row.names(MIBpa)),]==1||MIBpa[match("AARA-012",row.names(MIBpa)),]==1){
    Hyd2=4} else
{if(MIBpa[match("AARA-001",row.names(MIBpa)),]==0&&MIBpa[match("AARA-002",row.names(MIBpa)),]==0&&MIBpa[match("AARA-003",row.names(MIBpa)),]==0&&MIBpa[match("AARA-004",row.names(MIBpa)),]==0&&

 MIBpa[match("AARA-005",row.names(MIBpa)),]==0&&MIBpa[match("AARA-006",row.names(MIBpa)),]==0&&MIBpa[match("AARA-007",row.names(MIBpa)),]==0&&MIBpa[match("AARA-008",row.names(MIBpa)),]==0&&

 MIBpa[match("AARA-009",row.names(MIBpa)),]==0&&MIBpa[match("AARA-010",row.names(MIBpa)),]==0&&MIBpa[match("AARA-011",row.names(MIBpa)),]==0&&MIBpa[match("AARA-012",row.names(MIBpa)),]==0){
      Hyd2=0}}
  aesh1<-6*MIBpa[match("AINS-001",row.names(MIBpa)),]
  calo1<-8*MIBpa[match("AINS-002",row.names(MIBpa)),]
  coen1<-6*MIBpa[match("AINS-003",row.names(MIBpa)),]
  libe1<-6*MIBpa[match("AINS-004",row.names(MIBpa)),]

if(MIBpa[match("AINS-005",row.names(MIBpa)),]==1||MIBpa[match("AINS-006",row.names(MIBpa)),]==1||MIBpa[match("AINS-007",row.names(MIBpa)),]==1||MIBpa[match("AINS-008",row.names(MIBpa)),]==1||

 MIBpa[match("AINS-009",row.names(MIBpa)),]==1||MIBpa[match("AINS-010",row.names(MIBpa)),]==1||MIBpa[match("AINS-011",row.names(MIBpa)),]==1||MIBpa[match("AINS-012",row.names(MIBpa)),]==1){
    baet1=4} else
{if(MIBpa[match("AINS-005",row.names(MIBpa)),]==0&&MIBpa[match("AINS-006",row.names(MIBpa)),]==0&&MIBpa[match("AINS-007",row.names(MIBpa)),]==0&&MIBpa[match("AINS-008",row.names(MIBpa)),]==0&&

MIBpa[match("AINS-009",row.names(MIBpa)),]==0&&MIBpa[match("AINS-010",row.names(MIBpa)),]==0&&MIBpa[match("AINS-011",row.names(MIBpa)),]==0&&MIBpa[match("AINS-012",row.names(MIBpa)),]==0){
      baet1=0}}

if(MIBpa[match("AINS-013",row.names(MIBpa)),]==1||MIBpa[match("AINS-014",row.names(MIBpa)),]==1||MIBpa[match("AINS-015",row.names(MIBpa)),]==1){
    leph1=7} else
{if(MIBpa[match("AINS-013",row.names(MIBpa)),]==0&&MIBpa[match("AINS-014",row.names(MIBpa)),]==0&&MIBpa[match("AINS-015",row.names(MIBpa)),]==0){
      leph1=0}}

if(MIBpa[match("AINS-016",row.names(MIBpa)),]==1||MIBpa[match("AINS-017",row.names(MIBpa)),]==1){
    lepp1=10} else
{if(MIBpa[match("AINS-016",row.names(MIBpa)),]==0&&MIBpa[match("AINS-017",row.names(MIBpa)),]==0){
      lepp1=0}}
  olin1<-10*MIBpa[match("AINS-018",row.names(MIBpa)),]
  grip1<-10*MIBpa[match("AINS-019",row.names(MIBpa)),]

if(MIBpa[match("AINS-020",row.names(MIBpa)),]==1||MIBpa[match("AINS-021",row.names(MIBpa)),]==1||MIBpa[match("AINS-022",row.names(MIBpa)),]==1){
    perl1=10} else
{if(MIBpa[match("AINS-020",row.names(MIBpa)),]==0&&MIBpa[match("AINS-021",row.names(MIBpa)),]==0&&MIBpa[match("AINS-022",row.names(MIBpa)),]==0){
      perl1=0}}

if(MIBpa[match("AINS-023",row.names(MIBpa)),]==1||MIBpa[match("AINS-024",row.names(MIBpa)),]==1){
    cori1=5} else
{if(MIBpa[match("AINS-023",row.names(MIBpa)),]==0&&MIBpa[match("AINS-024",row.names(MIBpa)),]==0){
      cori1=0}}
  nauc1<-5*MIBpa[match("AINS-025",row.names(MIBpa)),]
  veli1<-5*MIBpa[match("AINS-026",row.names(MIBpa)),]
  Ble2<-10*MIBpa[match("AINS-027",row.names(MIBpa)),]

if(MIBpa[match("AINS-028",row.names(MIBpa)),]==1||MIBpa[match("AINS-029",row.names(MIBpa)),]==1||MIBpa[match("AINS-030",row.names(MIBpa)),]==1||MIBpa[match("AINS-031",row.names(MIBpa)),]==1

 ||MIBpa[match("AINS-032",row.names(MIBpa)),]==1||MIBpa[match("AINS-033",row.names(MIBpa)),]==1){
    cera1=4} else
{if(MIBpa[match("AINS-028",row.names(MIBpa)),]==0&&MIBpa[match("AINS-029",row.names(MIBpa)),]==0&&MIBpa[match("AINS-030",row.names(MIBpa)),]==0&&MIBpa[match("AINS-031",row.names(MIBpa)),]==0

&&MIBpa[match("AINS-032",row.names(MIBpa)),]==0&&MIBpa[match("AINS-033",row.names(MIBpa)),]==0){
      cera1=0}}

if(MIBpa[match("AINS-034",row.names(MIBpa)),]==1||MIBpa[match("AINS-035",row.names(MIBpa)),]==1||MIBpa[match("AINS-036",row.names(MIBpa)),]==1||MIBpa[match("AINS-037",row.names(MIBpa)),]==1||

 MIBpa[match("AINS-038",row.names(MIBpa)),]==1||MIBpa[match("AINS-039",row.names(MIBpa)),]==1||MIBpa[match("AINS-040",row.names(MIBpa)),]==1||MIBpa[match("AINS-041",row.names(MIBpa)),]==1

 ||MIBpa[match("AINS-042",row.names(MIBpa)),]==1||MIBpa[match("AINS-043",row.names(MIBpa)),]==1||MIBpa[match("AINS-044",row.names(MIBpa)),]==1||MIBpa[match("AINS-045",row.names(MIBpa)),]==1

 ||MIBpa[match("AINS-046",row.names(MIBpa)),]==1||MIBpa[match("AINS-047",row.names(MIBpa)),]==1||MIBpa[match("AINS-048",row.names(MIBpa)),]==1||MIBpa[match("AINS-049",row.names(MIBpa)),]==1

 ||MIBpa[match("AINS-050",row.names(MIBpa)),]==1||MIBpa[match("AINS-051",row.names(MIBpa)),]==1||MIBpa[match("AINS-052",row.names(MIBpa)),]==1||MIBpa[match("AINS-053",row.names(MIBpa)),]==1

 ||MIBpa[match("AINS-054",row.names(MIBpa)),]==1||MIBpa[match("AINS-055",row.names(MIBpa)),]==1||MIBpa[match("AINS-056",row.names(MIBpa)),]==1||MIBpa[match("AINS-057",row.names(MIBpa)),]==1

 ||MIBpa[match("AINS-058",row.names(MIBpa)),]==1||MIBpa[match("AINS-059",row.names(MIBpa)),]==1||MIBpa[match("AINS-060",row.names(MIBpa)),]==1||MIBpa[match("AINS-061",row.names(MIBpa)),]==1

 ||MIBpa[match("AINS-062",row.names(MIBpa)),]==1||MIBpa[match("AINS-063",row.names(MIBpa)),]==1){
    chri1=2} else
{if(MIBpa[match("AINS-034",row.names(MIBpa)),]==0&&MIBpa[match("AINS-035",row.names(MIBpa)),]==0&&MIBpa[match("AINS-036",row.names(MIBpa)),]==0&&MIBpa[match("AINS-037",row.names(MIBpa)),]==0&&

MIBpa[match("AINS-038",row.names(MIBpa)),]==0&&MIBpa[match("AINS-039",row.names(MIBpa)),]==0&&MIBpa[match("AINS-040",row.names(MIBpa)),]==0&&MIBpa[match("AINS-041",row.names(MIBpa)),]==0

&&MIBpa[match("AINS-042",row.names(MIBpa)),]==0&&MIBpa[match("AINS-043",row.names(MIBpa)),]==0&&MIBpa[match("AINS-044",row.names(MIBpa)),]==0&&MIBpa[match("AINS-045",row.names(MIBpa)),]==0

&&MIBpa[match("AINS-046",row.names(MIBpa)),]==0&&MIBpa[match("AINS-047",row.names(MIBpa)),]==0&&MIBpa[match("AINS-048",row.names(MIBpa)),]==0&&MIBpa[match("AINS-049",row.names(MIBpa)),]==0

&&MIBpa[match("AINS-050",row.names(MIBpa)),]==0&&MIBpa[match("AINS-051",row.names(MIBpa)),]==0&&MIBpa[match("AINS-052",row.names(MIBpa)),]==0&&MIBpa[match("AINS-053",row.names(MIBpa)),]==0

&&MIBpa[match("AINS-054",row.names(MIBpa)),]==0&&MIBpa[match("AINS-055",row.names(MIBpa)),]==0&&MIBpa[match("AINS-056",row.names(MIBpa)),]==0&&MIBpa[match("AINS-057",row.names(MIBpa)),]==0

&&MIBpa[match("AINS-058",row.names(MIBpa)),]==0&&MIBpa[match("AINS-059",row.names(MIBpa)),]==0&&MIBpa[match("AINS-060",row.names(MIBpa)),]==0&&MIBpa[match("AINS-061",row.names(MIBpa)),]==0

&&MIBpa[match("AINS-062",row.names(MIBpa)),]==0&&MIBpa[match("AINS-063",row.names(MIBpa)),]==0){
      chri1=0}}

if(MIBpa[match("AINS-064",row.names(MIBpa)),]==1||MIBpa[match("AINS-065",row.names(MIBpa)),]==1){
    empi1=4} else
{if(MIBpa[match("AINS-064",row.names(MIBpa)),]==0&&MIBpa[match("AINS-065",row.names(MIBpa)),]==0){
      empi1=0}}
  ephy1<-2*MIBpa[match("AINS-066",row.names(MIBpa)),]

if(MIBpa[match("AINS-067",row.names(MIBpa)),]==1||MIBpa[match("AINS-068",row.names(MIBpa)),]==1){
    musc1=2} else
{if(MIBpa[match("AINS-067",row.names(MIBpa)),]==0&&MIBpa[match("AINS-068",row.names(MIBpa)),]==0){
      musc1=0}}
  psyc1<-3*MIBpa[match("AINS-069",row.names(MIBpa)),]

if(MIBpa[match("AINS-070",row.names(MIBpa)),]==1||MIBpa[match("AINS-071",row.names(MIBpa)),]==1||MIBpa[match("AINS-072",row.names(MIBpa)),]==1||MIBpa[match("AINS-073",row.names(MIBpa)),]==1

 ||MIBpa[match("AINS-074",row.names(MIBpa)),]==1||MIBpa[match("AINS-075",row.names(MIBpa)),]==1||MIBpa[match("AINS-076",row.names(MIBpa)),]==1||MIBpa[match("AINS-077",row.names(MIBpa)),]==1
  ){
    simu1=5} else
{if(MIBpa[match("AINS-070",row.names(MIBpa)),]==0&&MIBpa[match("AINS-071",row.names(MIBpa)),]==0&&MIBpa[match("AINS-072",row.names(MIBpa)),]==0&&MIBpa[match("AINS-073",row.names(MIBpa)),]==0

&&MIBpa[match("AINS-074",row.names(MIBpa)),]==0&&MIBpa[match("AINS-075",row.names(MIBpa)),]==0&&MIBpa[match("AINS-076",row.names(MIBpa)),]==0&&MIBpa[match("AINS-077",row.names(MIBpa)),]==0
    ){
      simu1=0}}
  taba1<-4*MIBpa[match("AINS-078",row.names(MIBpa)),]

if(MIBpa[match("AINS-078",row.names(MIBpa)),]==1||MIBpa[match("AINS-079",row.names(MIBpa)),]==1
  ){
    taba1=4} else
{if(MIBpa[match("AINS-078",row.names(MIBpa)),]==0&&MIBpa[match("AINS-079",row.names(MIBpa)),]==0
    ){
      taba1=0}}

if(MIBpa[match("AINS-080",row.names(MIBpa)),]==1||MIBpa[match("AINS-081",row.names(MIBpa)),]==1||MIBpa[match("AINS-082",row.names(MIBpa)),]==1||MIBpa[match("AINS-083",row.names(MIBpa)),]==1
     ||MIBpa[match("AINS-084",row.names(MIBpa)),]==1
  ){
    tipu1=5} else
{if(MIBpa[match("AINS-080",row.names(MIBpa)),]==0&&MIBpa[match("AINS-081",row.names(MIBpa)),]==0&&MIBpa[match("AINS-082",row.names(MIBpa)),]==0&&MIBpa[match("AINS-083",row.names(MIBpa)),]==0
                      &&MIBpa[match("AINS-084",row.names(MIBpa)),]==0
    ){
      tipu1=0}}
  Cory2<-4*MIBpa[match("AINS-085",row.names(MIBpa)),]

if(MIBpa[match("AINS-086",row.names(MIBpa)),]==1||MIBpa[match("AINS-087",row.names(MIBpa)),]==1||MIBpa[match("AINS-088",row.names(MIBpa)),]==1||MIBpa[match("AINS-089",row.names(MIBpa)),]==1
     ||MIBpa[match("AINS-090",row.names(MIBpa)),]==1
  ){
    Dyt2=4} else
{if(MIBpa[match("AINS-086",row.names(MIBpa)),]==0&&MIBpa[match("AINS-087",row.names(MIBpa)),]==0&&MIBpa[match("AINS-088",row.names(MIBpa)),]==0&&MIBpa[match("AINS-089",row.names(MIBpa)),]==0
                     &&MIBpa[match("AINS-090",row.names(MIBpa)),]==0
    ){
      Dyt2=0}}

if(MIBpa[match("AINS-091",row.names(MIBpa)),]==1||MIBpa[match("AINS-092",row.names(MIBpa)),]==1||MIBpa[match("AINS-093",row.names(MIBpa)),]==1||MIBpa[match("AINS-094",row.names(MIBpa)),]==1

 ||MIBpa[match("AINS-095",row.names(MIBpa)),]==1||MIBpa[match("AINS-096",row.names(MIBpa)),]==1||MIBpa[match("AINS-097",row.names(MIBpa)),]==1||MIBpa[match("AINS-098",row.names(MIBpa)),]==1
  ){
    emi1=5} else
{if(MIBpa[match("AINS-091",row.names(MIBpa)),]==0&&MIBpa[match("AINS-092",row.names(MIBpa)),]==0&&MIBpa[match("AINS-093",row.names(MIBpa)),]==0&&MIBpa[match("AINS-094",row.names(MIBpa)),]==0

 &&MIBpa[match("AINS-095",row.names(MIBpa)),]==0&&MIBpa[match("AINS-096",row.names(MIBpa)),]==0&&MIBpa[match("AINS-097",row.names(MIBpa)),]==0&&MIBpa[match("AINS-098",row.names(MIBpa)),]==0
    ){
      emi1=0}}
  gyri1<-3*MIBpa[match("AINS-099",row.names(MIBpa)),]

if(MIBpa[match("AINS-100",row.names(MIBpa)),]==1||MIBpa[match("AINS-101",row.names(MIBpa)),]==1
  ){
    hyph1=3} else
{if(MIBpa[match("AINS-100",row.names(MIBpa)),]==0&&MIBpa[match("AINS-101",row.names(MIBpa)),]==0
    ){
      hyph1=0}}
  psep1<-5*MIBpa[match("AINS-102",row.names(MIBpa)),]

if(MIBpa[match("AINS-103",row.names(MIBpa)),]==1||MIBpa[match("AINS-104",row.names(MIBpa)),]==1
  ){
    ptil1=5} else
{if(MIBpa[match("AINS-103",row.names(MIBpa)),]==0&&MIBpa[match("AINS-104",row.names(MIBpa)),]==0
    ){
      ptil1=0}}

if(MIBpa[match("AINS-105",row.names(MIBpa)),]==1||MIBpa[match("AINS-106",row.names(MIBpa)),]==1||MIBpa[match("AINS-107",row.names(MIBpa)),]==1
  ){
    scir1=5} else
{if(MIBpa[match("AINS-105",row.names(MIBpa)),]==0&&MIBpa[match("AINS-106",row.names(MIBpa)),]==0&&MIBpa[match("AINS-107",row.names(MIBpa)),]==0
    ){
      scir1=0}}

if(MIBpa[match("AINS-108",row.names(MIBpa)),]==1||MIBpa[match("AINS-109",row.names(MIBpa)),]==1
){
    cala1=10} else
{if(MIBpa[match("AINS-108",row.names(MIBpa)),]==0&&MIBpa[match("AINS-109",row.names(MIBpa)),]==0
    ){
      cala1=0}}
  glos1<-7*MIBpa[match("AINS-110",row.names(MIBpa)),]
  heli1<-10*MIBpa[match("AINS-111",row.names(MIBpa)),]

if(MIBpa[match("AINS-112",row.names(MIBpa)),]==1||MIBpa[match("AINS-113",row.names(MIBpa)),]==1||MIBpa[match("AINS-114",row.names(MIBpa)),]==1||MIBpa[match("AINS-115",row.names(MIBpa)),]==1

 ||MIBpa[match("AINS-116",row.names(MIBpa)),]==1||MIBpa[match("AINS-117",row.names(MIBpa)),]==1
  ){
    hyio1=8} else
{if(MIBpa[match("AINS-112",row.names(MIBpa)),]==0&&MIBpa[match("AINS-113",row.names(MIBpa)),]==0&&MIBpa[match("AINS-114",row.names(MIBpa)),]==0&&MIBpa[match("AINS-115",row.names(MIBpa)),]==0

&&MIBpa[match("AINS-116",row.names(MIBpa)),]==0&&MIBpa[match("AINS-117",row.names(MIBpa)),]==0
    ){
      hyio1=0}}

if(MIBpa[match("AINS-118",row.names(MIBpa)),]==1||MIBpa[match("AINS-119",row.names(MIBpa)),]==1||MIBpa[match("AINS-120",row.names(MIBpa)),]==1||MIBpa[match("AINS-121",row.names(MIBpa)),]==1
  ){
    hyps1=5} else
{if(MIBpa[match("AINS-118",row.names(MIBpa)),]==0&&MIBpa[match("AINS-119",row.names(MIBpa)),]==0&&MIBpa[match("AINS-120",row.names(MIBpa)),]==0&&MIBpa[match("AINS-121",row.names(MIBpa)),]==0
    ){
      hyps1=0}}

if(MIBpa[match("AINS-122",row.names(MIBpa)),]==1||MIBpa[match("AINS-123",row.names(MIBpa)),]==1||MIBpa[match("AINS-124",row.names(MIBpa)),]==1
  ){
    hypt1=6} else
{if(MIBpa[match("AINS-122",row.names(MIBpa)),]==0&&MIBpa[match("AINS-123",row.names(MIBpa)),]==0&&MIBpa[match("AINS-124",row.names(MIBpa)),]==0
    ){
      hypt1=0}}

if(MIBpa[match("AINS-125",row.names(MIBpa)),]==1||MIBpa[match("AINS-126",row.names(MIBpa)),]==1
  ){
    lepc1=8} else
{if(MIBpa[match("AINS-125",row.names(MIBpa)),]==0&&MIBpa[match("AINS-126",row.names(MIBpa)),]==0
    ){
      lepc1=0}}
  lime1<-7*MIBpa[match("AINS-127",row.names(MIBpa)),]

if(MIBpa[match("AINS-128",row.names(MIBpa)),]==1||MIBpa[match("AINS-129",row.names(MIBpa)),]==1
  ){
    Cram2=4} else
{if(MIBpa[match("AINS-128",row.names(MIBpa)),]==0&&MIBpa[match("AINS-129",row.names(MIBpa)),]==0
    ){
      Cram2=0}}
#
 Data1<-data.frame(turb1,Coc2,Lym2,phys1,Cor2,Sph2,Oli2,Glo2,Dap2,Hya2,Pal2,Hyd2,aesh1,calo1,coen1,libe1,baet1,leph1,lepp1,olin1,grip1,perl1,cori1,nauc1,veli1,Ble2,cera1,chri1,empi1,ephy1,musc1,psyc1,simu1,taba1,tipu1,Cory2,Dyt2,elmi1,gyri1,
#
 hyph1,psep1,ptil1,scir1,cala1,glos1,heli1,hyio1,hyps1,hypt1,lepc1,lime1,Cram2)

Data1<-data.frame(turb1,Coc2,Lym2,phys1,Cor2,Sph2,Oli2,Glo2,Dap2,Hya2,Pal2,Hyd2,aesh1,calo1,coen1,libe1,baet1,leph1,lepp1,olin1,grip1,perl1,cori1,nauc1,veli1,Ble2,cera1,chri1,empi1,ephy1,musc1,psyc1,simu1,taba1,tipu1,Cory2,Dyt2,gyri1,

hyph1,psep1,ptil1,scir1,cala1,glos1,heli1,hyio1,hyps1,hypt1,lepc1,lime1,Cram2)
  Data2<-t(Data1)
  ABI1<-colSums(Data2,na.rm=T)
  print(ABI1)
}


#########################################



Saludos,
Carlos Ortega
www.qualityexcellence.es


El 25 de enero de 2013 15:44, Gabriel Trujillo Paucar <
gabriel_enter@hotmail.com> escribió:

>
> Gracias, lo pude corregir, sin embargo cuando corro mi funcion final me
> sale ahora este mensaje:
> Error in if (MIBpa[match("AINS-005", row.names(MIBpa)), ] == 1 ||
> MIBpa[match("AINS-006",  :
>   missing value where TRUE/FALSE needed
> Me he cerciorado varias veces en esa parte de mi funcion y no encuentro
> algo que este fuera de su lugar. Les adjunto mi funcion y la bateria de
> datos que uso para correrla:
> #####################################
>
> ABI <- function(x){
> MIBpa <- x
> turb1<-5*MIBpa[match("PTUR-001",row.names(MIBpa)),]
>
> if(MIBpa[match("MGAS-001",row.names(MIBpa)),]==1||MIBpa[match("MGAS-002",row.names(MIBpa)),]==1){
>  Coc2=3} else
> {if(MIBpa[match("MGAS-001",row.names(MIBpa)),]==0&&MIBpa[match("MGAS-002",row.names(MIBpa)),]==0){
>  Coc2=0}}
> Lym2<-3*MIBpa[match("MGAS-003",row.names(MIBpa)),]
> phys1<-3*MIBpa[match("MGAS-004",row.names(MIBpa)),]
> Cor2<-3*MIBpa[match("MBIV-001",row.names(MIBpa)),]
> Sph2<-3*MIBpa[match("MBIV-002",row.names(MIBpa)),]
>
> if(MIBpa[match("NCLI-001",row.names(MIBpa)),]==1||MIBpa[match("NCLI-002",row.names(MIBpa)),]==1||MIBpa[match("NCLI-003",row.names(MIBpa)),]==1||MIBpa[match("NCLI-004",row.names(MIBpa)),]==1||
>
>  MIBpa[match("NCLI-005",row.names(MIBpa)),]==1||MIBpa[match("NCLI-006",row.names(MIBpa)),]==1||MIBpa[match("NCLI-007",row.names(MIBpa)),]==1||MIBpa[match("NCLI-008",row.names(MIBpa)),]==1){
>  Oli2=1} else
> {if(MIBpa[match("NCLI-001",row.names(MIBpa)),]==0&&MIBpa[match("NCLI-002",row.names(MIBpa)),]==0&&MIBpa[match("NCLI-003",row.names(MIBpa)),]==0&&MIBpa[match("NCLI-004",row.names(MIBpa)),]==0&&
>
>  MIBpa[match("NCLI-005",row.names(MIBpa)),]==0&&MIBpa[match("NCLI-006",row.names(MIBpa)),]==0&&MIBpa[match("NCLI-007",row.names(MIBpa)),]==0&&MIBpa[match("NCLI-008",row.names(MIBpa)),]==0){
>  Oli2=0}}
>
> if(MIBpa[match("NHIR-001",row.names(MIBpa)),]==1||MIBpa[match("NHIR-002",row.names(MIBpa)),]==1){
>  Glo2=3} else
> {if(MIBpa[match("NHIR-001",row.names(MIBpa)),]==0&&MIBpa[match("NHIR-002",row.names(MIBpa)),]==0){
>  Glo2=0}}
> Dap2<-3*MIBpa[match("AMAL-001",row.names(MIBpa)),]
>
> if(MIBpa[match("AMAL-002",row.names(MIBpa)),]==1||MIBpa[match("AMAL-003",row.names(MIBpa)),]==1){
>  Hya2=6} else
> {if(MIBpa[match("AMAL-002",row.names(MIBpa)),]==0&&MIBpa[match("AMAL-003",row.names(MIBpa)),]==0){
>  Hya2=0}}
> Pal2<-6*MIBpa[match("AMAL-004",row.names(MIBpa)),]
>
> if(MIBpa[match("AARA-001",row.names(MIBpa)),]==1||MIBpa[match("AARA-002",row.names(MIBpa)),]==1||MIBpa[match("AARA-003",row.names(MIBpa)),]==1||MIBpa[match("AARA-004",row.names(MIBpa)),]==1||
>
>  MIBpa[match("AARA-005",row.names(MIBpa)),]==1||MIBpa[match("AARA-006",row.names(MIBpa)),]==1||MIBpa[match("AARA-007",row.names(MIBpa)),]==1||MIBpa[match("AARA-008",row.names(MIBpa)),]==1||
>
>  MIBpa[match("AARA-009",row.names(MIBpa)),]==1||MIBpa[match("AARA-010",row.names(MIBpa)),]==1||MIBpa[match("AARA-011",row.names(MIBpa)),]==1||MIBpa[match("AARA-012",row.names(MIBpa)),]==1){
>  Hyd2=4} else
> {if(MIBpa[match("AARA-001",row.names(MIBpa)),]==0&&MIBpa[match("AARA-002",row.names(MIBpa)),]==0&&MIBpa[match("AARA-003",row.names(MIBpa)),]==0&&MIBpa[match("AARA-004",row.names(MIBpa)),]==0&&
>
>  MIBpa[match("AARA-005",row.names(MIBpa)),]==0&&MIBpa[match("AARA-006",row.names(MIBpa)),]==0&&MIBpa[match("AARA-007",row.names(MIBpa)),]==0&&MIBpa[match("AARA-008",row.names(MIBpa)),]==0&&
>
>  MIBpa[match("AARA-009",row.names(MIBpa)),]==0&&MIBpa[match("AARA-010",row.names(MIBpa)),]==0&&MIBpa[match("AARA-011",row.names(MIBpa)),]==0&&MIBpa[match("AARA-012",row.names(MIBpa)),]==0){
>  Hyd2=0}}
> aesh1<-6*MIBpa[match("AINS-001",row.names(MIBpa)),]
> calo1<-8*MIBpa[match("AINS-002",row.names(MIBpa)),]
> coen1<-6*MIBpa[match("AINS-003",row.names(MIBpa)),]
> libe1<-6*MIBpa[match("AINS-004",row.names(MIBpa)),]
>
> if(MIBpa[match("AINS-005",row.names(MIBpa)),]==1||MIBpa[match("AINS-006",row.names(MIBpa)),]==1||MIBpa[match("AINS-007",row.names(MIBpa)),]==1||MIBpa[match("AINS-008",row.names(MIBpa)),]==1||
>
>  MIBpa[match("AINS-009",row.names(MIBpa)),]==1||MIBpa[match("AINS-010",row.names(MIBpa)),]==1||MIBpa[match("AINS-011",row.names(MIBpa)),]==1||MIBpa[match("AIMS-012",row.names(MIBpa)),]==1){
>  baet1=4} else
> {if(MIBpa[match("AINS-005",row.names(MIBpa)),]==0&&MIBpa[match("AINS-006",row.names(MIBpa)),]==0&&MIBpa[match("AINS-007",row.names(MIBpa)),]==0&&MIBpa[match("AINS-008",row.names(MIBpa)),]==0&&
>
>  MIBpa[match("AINS-009",row.names(MIBpa)),]==0&&MIBpa[match("AINS-010",row.names(MIBpa)),]==0&&MIBpa[match("AINS-011",row.names(MIBpa)),]==0&&MIBpa[match("AINS-012",row.names(MIBpa)),]==0){
>  baet1=0}}
>
> if(MIBpa[match("AINS-013",row.names(MIBpa)),]==1||MIBpa[match("AINS-014",row.names(MIBpa)),]==1||MIBpa[match("AINS-015",row.names(MIBpa)),]==1){
>  leph1=7} else
> {if(MIBpa[match("AINS-013",row.names(MIBpa)),]==0&&MIBpa[match("AINS-014",row.names(MIBpa)),]==0&&MIBpa[match("AINS-015",row.names(MIBpa)),]==0){
>  leph1=0}}
>
> if(MIBpa[match("AINS-016",row.names(MIBpa)),]==1||MIBpa[match("AINS-017",row.names(MIBpa)),]==1){
>  lepp1=10} else
> {if(MIBpa[match("AINS-016",row.names(MIBpa)),]==0&&MIBpa[match("AINS-017",row.names(MIBpa)),]==0){
>  lepp1=0}}
> olin1<-10*MIBpa[match("AINS-018",row.names(MIBpa)),]
> grip1<-10*MIBpa[match("AINS-019",row.names(MIBpa)),]
>
> if(MIBpa[match("AINS-020",row.names(MIBpa)),]==1||MIBpa[match("AINS-021",row.names(MIBpa)),]==1||MIBpa[match("AINS-022",row.names(MIBpa)),]==1){
>  perl1=10} else
> {if(MIBpa[match("AINS-020",row.names(MIBpa)),]==0&&MIBpa[match("AINS-021",row.names(MIBpa)),]==0&&MIBpa[match("AINS-022",row.names(MIBpa)),]==0){
>  perl1=0}}
>
> if(MIBpa[match("AINS-023",row.names(MIBpa)),]==1||MIBpa[match("AINS-024",row.names(MIBpa)),]==1){
>  cori1=5} else
> {if(MIBpa[match("AINS-023",row.names(MIBpa)),]==0&&MIBpa[match("AINS-024",row.names(MIBpa)),]==0){
>  cori1=0}}
> nauc1<-5*MIBpa[match("AINS-025",row.names(MIBpa)),]
> veli1<-5*MIBpa[match("AINS-026",row.names(MIBpa)),]
> Ble2<-10*MIBpa[match("AINS-027",row.names(MIBpa)),]
>
> if(MIBpa[match("AINS-028",row.names(MIBpa)),]==1||MIBpa[match("AINS-029",row.names(MIBpa)),]==1||MIBpa[match("AINS-030",row.names(MIBpa)),]==1||MIBpa[match("AINS-031",row.names(MIBpa)),]==1
>
>  ||MIBpa[match("AINS-032",row.names(MIBpa)),]==1||MIBpa[match("AINS-033",row.names(MIBpa)),]==1){
>  cera1=4} else
> {if(MIBpa[match("AINS-028",row.names(MIBpa)),]==0&&MIBpa[match("AINS-029",row.names(MIBpa)),]==0&&MIBpa[match("AINS-030",row.names(MIBpa)),]==0&&MIBpa[match("AINS-031",row.names(MIBpa)),]==0
>
>  &&MIBpa[match("AINS-032",row.names(MIBpa)),]==0&&MIBpa[match("AINS-033",row.names(MIBpa)),]==0){
>  cera1=0}}
>
> if(MIBpa[match("AINS-034",row.names(MIBpa)),]==1||MIBpa[match("AINS-035",row.names(MIBpa)),]==1||MIBpa[match("AINS-036",row.names(MIBpa)),]==1||MIBpa[match("AINS-037",row.names(MIBpa)),]==1||
>
>  MIBpa[match("AINS-038",row.names(MIBpa)),]==1||MIBpa[match("AINS-039",row.names(MIBpa)),]==1||MIBpa[match("AINS-040",row.names(MIBpa)),]==1||MIBpa[match("AIMS-041",row.names(MIBpa)),]==1
>
>  ||MIBpa[match("AIMS-042",row.names(MIBpa)),]==1||MIBpa[match("AIMS-043",row.names(MIBpa)),]==1||MIBpa[match("AIMS-044",row.names(MIBpa)),]==1||MIBpa[match("AIMS-045",row.names(MIBpa)),]==1
>
>  ||MIBpa[match("AIMS-046",row.names(MIBpa)),]==1||MIBpa[match("AIMS-047",row.names(MIBpa)),]==1||MIBpa[match("AIMS-048",row.names(MIBpa)),]==1||MIBpa[match("AIMS-049",row.names(MIBpa)),]==1
>
>  ||MIBpa[match("AIMS-050",row.names(MIBpa)),]==1||MIBpa[match("AIMS-051",row.names(MIBpa)),]==1||MIBpa[match("AIMS-052",row.names(MIBpa)),]==1||MIBpa[match("AIMS-053",row.names(MIBpa)),]==1
>
>  ||MIBpa[match("AIMS-054",row.names(MIBpa)),]==1||MIBpa[match("AIMS-055",row.names(MIBpa)),]==1||MIBpa[match("AIMS-056",row.names(MIBpa)),]==1||MIBpa[match("AIMS-057",row.names(MIBpa)),]==1
>
>  ||MIBpa[match("AIMS-058",row.names(MIBpa)),]==1||MIBpa[match("AIMS-059",row.names(MIBpa)),]==1||MIBpa[match("AIMS-060",row.names(MIBpa)),]==1||MIBpa[match("AIMS-061",row.names(MIBpa)),]==1
>
>  ||MIBpa[match("AIMS-062",row.names(MIBpa)),]==1||MIBpa[match("AIMS-063",row.names(MIBpa)),]==1){
>  chri1=2} else
> {if(MIBpa[match("AINS-034",row.names(MIBpa)),]==0&&MIBpa[match("AINS-035",row.names(MIBpa)),]==0&&MIBpa[match("AINS-036",row.names(MIBpa)),]==0&&MIBpa[match("AINS-037",row.names(MIBpa)),]==0&&
>
>  MIBpa[match("AINS-038",row.names(MIBpa)),]==0&&MIBpa[match("AINS-039",row.names(MIBpa)),]==0&&MIBpa[match("AINS-040",row.names(MIBpa)),]==0&&MIBpa[match("AINS-041",row.names(MIBpa)),]==0
>
>  &&MIBpa[match("AINS-042",row.names(MIBpa)),]==0&&MIBpa[match("AINS-043",row.names(MIBpa)),]==0&&MIBpa[match("AINS-044",row.names(MIBpa)),]==0&&MIBpa[match("AINS-045",row.names(MIBpa)),]==0
>
>  &&MIBpa[match("AINS-046",row.names(MIBpa)),]==0&&MIBpa[match("AINS-047",row.names(MIBpa)),]==0&&MIBpa[match("AINS-048",row.names(MIBpa)),]==0&&MIBpa[match("AINS-049",row.names(MIBpa)),]==0
>
>  &&MIBpa[match("AINS-050",row.names(MIBpa)),]==0&&MIBpa[match("AINS-051",row.names(MIBpa)),]==0&&MIBpa[match("AINS-052",row.names(MIBpa)),]==0&&MIBpa[match("AINS-053",row.names(MIBpa)),]==0
>
>  &&MIBpa[match("AINS-054",row.names(MIBpa)),]==0&&MIBpa[match("AINS-055",row.names(MIBpa)),]==0&&MIBpa[match("AINS-056",row.names(MIBpa)),]==0&&MIBpa[match("AINS-057",row.names(MIBpa)),]==0
>
>  &&MIBpa[match("AINS-058",row.names(MIBpa)),]==0&&MIBpa[match("AINS-059",row.names(MIBpa)),]==0&&MIBpa[match("AINS-060",row.names(MIBpa)),]==0&&MIBpa[match("AINS-061",row.names(MIBpa)),]==0
>
>  &&MIBpa[match("AINS-062",row.names(MIBpa)),]==0&&MIBpa[match("AINS-063",row.names(MIBpa)),]==0){
>  chri1=0}}
>
> if(MIBpa[match("AINS-064",row.names(MIBpa)),]==1||MIBpa[match("AINS-065",row.names(MIBpa)),]==1){
>  empi1=4} else
> {if(MIBpa[match("AINS-064",row.names(MIBpa)),]==0&&MIBpa[match("AINS-065",row.names(MIBpa)),]==0){
>  empi1=0}}
> ephy1<-2*MIBpa[match("AINS-066",row.names(MIBpa)),]
>
> if(MIBpa[match("AINS-067",row.names(MIBpa)),]==1||MIBpa[match("AINS-068",row.names(MIBpa)),]==1){
>  musc1=2} else
> {if(MIBpa[match("AINS-067",row.names(MIBpa)),]==0&&MIBpa[match("AINS-068",row.names(MIBpa)),]==0){
>  musc1=0}}
> psyc1<-3*MIBpa[match("AINS-069",row.names(MIBpa)),]
>
> if(MIBpa[match("AINS-070",row.names(MIBpa)),]==1||MIBpa[match("AINS-071",row.names(MIBpa)),]==1||MIBpa[match("AINS-072",row.names(MIBpa)),]==1||MIBpa[match("AINS-073",row.names(MIBpa)),]==1
>
>  ||MIBpa[match("AINS-074",row.names(MIBpa)),]==1||MIBpa[match("AINS-075",row.names(MIBpa)),]==1||MIBpa[match("AINS-076",row.names(MIBpa)),]==1||MIBpa[match("AINS-077",row.names(MIBpa)),]==1
>  ){
>  simu1=5} else
> {if(MIBpa[match("AINS-070",row.names(MIBpa)),]==0&&MIBpa[match("AINS-071",row.names(MIBpa)),]==0&&MIBpa[match("AINS-072",row.names(MIBpa)),]==0&&MIBpa[match("AINS-073",row.names(MIBpa)),]==0
>
>  &&MIBpa[match("AINS-074",row.names(MIBpa)),]==0&&MIBpa[match("AINS-075",row.names(MIBpa)),]==0&&MIBpa[match("AINS-076",row.names(MIBpa)),]==0&&MIBpa[match("AINS-077",row.names(MIBpa)),]==0
>  ){
>  simu1=0}}
> taba1<-4*MIBpa[match("AINS-078",row.names(MIBpa)),]
>
> if(MIBpa[match("AINS-078",row.names(MIBpa)),]==1||MIBpa[match("AINS-079",row.names(MIBpa)),]==1
>  ){
>  taba1=4} else
> {if(MIBpa[match("AINS-078",row.names(MIBpa)),]==0&&MIBpa[match("AINS-079",row.names(MIBpa)),]==0
>  ){
>  taba1=0}}
>
> if(MIBpa[match("AINS-080",row.names(MIBpa)),]==1||MIBpa[match("AINS-081",row.names(MIBpa)),]==1||MIBpa[match("AINS-082",row.names(MIBpa)),]==1||MIBpa[match("AINS-083",row.names(MIBpa)),]==1
>  ||MIBpa[match("AINS-084",row.names(MIBpa)),]==1
>  ){
>  tipu1=5} else
> {if(MIBpa[match("AINS-080",row.names(MIBpa)),]==0&&MIBpa[match("AINS-081",row.names(MIBpa)),]==0&&MIBpa[match("AINS-082",row.names(MIBpa)),]==0&&MIBpa[match("AINS-083",row.names(MIBpa)),]==0
>  &&MIBpa[match("AINS-084",row.names(MIBpa)),]==0
>  ){
>  tipu1=0}}
> Cory2<-4*MIBpa[match("AINS-085",row.names(MIBpa)),]
>
> if(MIBpa[match("AINS-086",row.names(MIBpa)),]==1||MIBpa[match("AINS-087",row.names(MIBpa)),]==1||MIBpa[match("AINS-088",row.names(MIBpa)),]==1||MIBpa[match("AINS-089",row.names(MIBpa)),]==1
>  ||MIBpa[match("AINS-090",row.names(MIBpa)),]==1
>  ){
>  Dyt2=4} else
> {if(MIBpa[match("AINS-086",row.names(MIBpa)),]==0&&MIBpa[match("AINS-087",row.names(MIBpa)),]==0&&MIBpa[match("AINS-088",row.names(MIBpa)),]==0&&MIBpa[match("AINS-089",row.names(MIBpa)),]==0
>  &&MIBpa[match("AINS-090",row.names(MIBpa)),]==0
>  ){
>  Dyt2=0}}
>
> if(MIBpa[match("AINS-091",row.names(MIBpa)),]==1||MIBpa[match("AINS-092",row.names(MIBpa)),]==1||MIBpa[match("AINS-093",row.names(MIBpa)),]==1||MIBpa[match("AINS-094",row.names(MIBpa)),]==1
>
>  ||MIBpa[match("AINS-095",row.names(MIBpa)),]==1||MIBpa[match("AINS-096",row.names(MIBpa)),]==1||MIBpa[match("AINS-097",row.names(MIBpa)),]==1||MIBpa[match("AINS-098",row.names(MIBpa)),]==1
>  ){
>  emi1=5} else
> {if(MIBpa[match("AINS-091",row.names(MIBpa)),]==0&&MIBpa[match("AINS-092",row.names(MIBpa)),]==0&&MIBpa[match("AINS-093",row.names(MIBpa)),]==0&&MIBpa[match("AINS-094",row.names(MIBpa)),]==0
>
>  &&MIBpa[match("AINS-095",row.names(MIBpa)),]==0&&MIBpa[match("AINS-096",row.names(MIBpa)),]==0&&MIBpa[match("AINS-097",row.names(MIBpa)),]==0&&MIBpa[match("AINS-098",row.names(MIBpa)),]==0
>  ){
>  emi1=0}}
> gyri1<-3*MIBpa[match("AINS-099",row.names(MIBpa)),]
>
> if(MIBpa[match("AINS-100",row.names(MIBpa)),]==1||MIBpa[match("AINS-101",row.names(MIBpa)),]==1
>  ){
>  hyph1=3} else
> {if(MIBpa[match("AINS-100",row.names(MIBpa)),]==0&&MIBpa[match("AINS-101",row.names(MIBpa)),]==0
>  ){
>  hyph1=0}}
> psep1<-5*MIBpa[match("AINS-102",row.names(MIBpa)),]
>
> if(MIBpa[match("AINS-103",row.names(MIBpa)),]==1||MIBpa[match("AINS-104",row.names(MIBpa)),]==1
>  ){
>  ptil1=5} else
> {if(MIBpa[match("AINS-103",row.names(MIBpa)),]==0&&MIBpa[match("AINS-104",row.names(MIBpa)),]==0
>  ){
>  ptil1=0}}
>
> if(MIBpa[match("AINS-105",row.names(MIBpa)),]==1||MIBpa[match("AINS-106",row.names(MIBpa)),]==1||MIBpa[match("AINS-107",row.names(MIBpa)),]==1
>  ){
>  scir1=5} else
> {if(MIBpa[match("AINS-105",row.names(MIBpa)),]==0&&MIBpa[match("AINS-106",row.names(MIBpa)),]==0&&MIBpa[match("AINS-107",row.names(MIBpa)),]==0
>  ){
>  scir1=0}}
> if(MIBpa[match("AINS-108",row.names(MIBpa)),]==1||MIBpa[match("AINS-109",row.names(MIBpa)),]==1
> ){
>  cala1=10} else
> {if(MIBpa[match("AINS-108",row.names(MIBpa)),]==0&&MIBpa[match("AINS-109",row.names(MIBpa)),]==0
>  ){
>  cala1=0}}
> glos1<-7*MIBpa[match("AINS-110",row.names(MIBpa)),]
> heli1<-10*MIBpa[match("AINS-111",row.names(MIBpa)),]
>
> if(MIBpa[match("AINS-112",row.names(MIBpa)),]==1||MIBpa[match("AINS-113",row.names(MIBpa)),]==1||MIBpa[match("AINS-114",row.names(MIBpa)),]==1||MIBpa[match("AINS-115",row.names(MIBpa)),]==1
>
>  ||MIBpa[match("AINS-116",row.names(MIBpa)),]==1||MIBpa[match("AINS-117",row.names(MIBpa)),]==1
>  ){
>  hyio1=8} else
> {if(MIBpa[match("AINS-112",row.names(MIBpa)),]==0&&MIBpa[match("AINS-113",row.names(MIBpa)),]==0&&MIBpa[match("AINS-114",row.names(MIBpa)),]==0&&MIBpa[match("AINS-115",row.names(MIBpa)),]==0
>
>  &&MIBpa[match("AINS-116",row.names(MIBpa)),]==0&&MIBpa[match("AINS-117",row.names(MIBpa)),]==0
>  ){
>  hyio1=0}}
>
> if(MIBpa[match("AINS-118",row.names(MIBpa)),]==1||MIBpa[match("AINS-119",row.names(MIBpa)),]==1||MIBpa[match("AINS-120",row.names(MIBpa)),]==1||MIBpa[match("AINS-121",row.names(MIBpa)),]==1
>  ){
>  hyps1=5} else
> {if(MIBpa[match("AINS-118",row.names(MIBpa)),]==0&&MIBpa[match("AINS-119",row.names(MIBpa)),]==0&&MIBpa[match("AINS-120",row.names(MIBpa)),]==0&&MIBpa[match("AINS-121",row.names(MIBpa)),]==0
>  ){
>  hyps1=0}}
>
> if(MIBpa[match("AINS-122",row.names(MIBpa)),]==1||MIBpa[match("AINS-123",row.names(MIBpa)),]==1||MIBpa[match("AINS-124",row.names(MIBpa)),]==1
>  ){
>  hypt1=6} else
> {if(MIBpa[match("AINS-122",row.names(MIBpa)),]==0&&MIBpa[match("AINS-123",row.names(MIBpa)),]==0&&MIBpa[match("AINS-124",row.names(MIBpa)),]==0
>  ){
>  hypt1=0}}
>
> if(MIBpa[match("AINS-125",row.names(MIBpa)),]==1||MIBpa[match("AINS-126",row.names(MIBpa)),]==1
>  ){
>  lepc1=8} else
> {if(MIBpa[match("AINS-125",row.names(MIBpa)),]==0&&MIBpa[match("AINS-126",row.names(MIBpa)),]==0
>  ){
>  lepc1=0}}
> lime1<-7*MIBpa[match("AINS-127",row.names(MIBpa)),]
>
> if(MIBpa[match("AINS-128",row.names(MIBpa)),]==1||MIBpa[match("AINS-129",row.names(MIBpa)),]==1
>  ){
>  Cram2=4} else
> {if(MIBpa[match("AINS-128",row.names(MIBpa)),]==0&&MIBpa[match("AINS-129",row.names(MIBpa)),]==0
>  ){
>  Cram2=0}}
>
> Data1<-data.frame(turb1,Coc2,Lym2,phys1,Cor2,Sph2,Oli2,Glo2,Dap2,Hya2,Pal2,Hyd2,aesh1,calo1,coen1,libe1,baet1,leph1,lepp1,olin1,grip1,perl1,cori1,nauc1,veli1,Ble2,cera1,chri1,empi1,ephy1,musc1,psyc1,simu1,taba1,tipu1,Cory2,Dyt2,elmi1,gyri1,
>
>  hyph1,psep1,ptil1,scir1,cala1,glos1,heli1,hyio1,hyps1,hypt1,lepc1,lime1,Cram2)
> Data2<-t(Data1)
> ABI1<-colSums(Data2,na.rm=T)
> print(ABI)
> }
> #####################################
> Agradesco de antemano por su atencion y ayuda
> Gabriel Antonio Trujillo Paucar
> Estudiante de Biologia
>
> ________________________________
> > From: jorgeivanvelez@gmail.com
> > Date: Fri, 25 Jan 2013 09:39:20 +1100
> > Subject: Re: [R-es] Ayuda con el bucle if
> > To: gabriel_enter@hotmail.com
> > CC: evapcastro@yahoo.es; r-help-es@r-project.org
> >
> > Hola Gabriel,
> >
> > La solucion planteada por Eva funciona a la perfeccion. Sin embargo,
> > creo que te beneficiarias enormemente si revisaras las funciones
> > ?ifelse y ?"%in%"
> >
> > Saludos,
> > Jorge.-
> >
> >
> > 2013/1/25 Eva Prieto Castro <evapcastro@yahoo.es<mailto:
> evapcastro@yahoo.es>>
> > Hola, Gabriel:
> >
> > La función corregida es ésta:
> >
> >
> > ABI <- function(x){
> > MIBpa <- x
> > turb1<-5*MIBpa[match("PTUR-001",row.names(MIBpa)),]
> >
> if(MIBpa[match("MGAS-001",row.names(MIBpa)),]==1||MIBpa[match("MGAS-002",row.names(MIBpa)),]==1){
> > Coc2=3} else
> >
> {if(MIBpa[match("MGAS-001",row.names(MIBpa)),]==0&&MIBpa[match("MGAS-002",row.names(MIBpa)),]==0){
> > Coc2=0}}}
> >
> > Tenías un row en lugar de un row.names.
> >
> > Saludos.
> >
> > Eva
> >
> >
> > --- El jue, 24/1/13, Gabriel Trujillo Paucar
> > <gabriel_enter@hotmail.com<mailto:gabriel_enter@hotmail.com>> escribió:
> >
> > De: Gabriel Trujillo Paucar
> > <gabriel_enter@hotmail.com<mailto:gabriel_enter@hotmail.com>>
> > Asunto: RE: [R-es] Ayuda con el bucle if
> > Para: "evapcastro@yahoo.es<mailto:evapcastro@yahoo.es>"
> > <evapcastro@yahoo.es<mailto:evapcastro@yahoo.es>>,
> > jorgeivanvelez@gmail.com<mailto:jorgeivanvelez@gmail.com>
> > CC: "r-help-es@r-project.org<mailto:r-help-es@r-project.org>"
> > <r-help-es@r-project.org<mailto:r-help-es@r-project.org>>
> > Fecha: jueves, 24 de enero, 2013 21:58
> >
> >
> >
> > Saludos una ultima pregunta, he creado una funcion en el bucle if la
> cual es:
> > #####################################
> >
> > ABI <- function(x){
> > MIBpa <- x
> > turb1<-5*MIBpa[match("PTUR-001",row.names(MIBpa)),]
> >
> if(MIBpa[match("MGAS-001",row.names(MIBpa)),]==1||MIBpa[match("MGAS-002",row.names(MIBpa)),]==1){
> > Coc2=3} else
> >
> {if(MIBpa[match("MGAS-001",row(MIBpa)),]==0&&MIBpa[match("MGAS-002",row.names(MIBpa)),]==0){
> > Coc2=0}}}
> > #####################################
> > y tengo mi matriz :
> > #####################################
> > a=data.frame(M1=c(1,0,0),row.names=c("PTUR-001","MGAS-001","MGAS-002"))
> > #####################################
> > Cuando corro la funcion con mi matriz "a" me sale el siguiente mensaje:
> > Error in if (MIBpa[match("MGAS-001", row(MIBpa)), ] == 0 &&
> > MIBpa[match("MGAS-002", :
> > missing value where TRUE/FALSE needed
> > No se donde estaria mi error, porque lo que deseo en el bucle if es que
> > el objeto "Coc2" que crea me de valor de 3 cuando en el data.frame para
> > la fila"MGAS-001" o "MGAS-002" tengan valor de 1 cualquiera de los dos
> > y en el caso de que ambos sean ceros, el objeto "Coc2" me de un valor
> > de "0".
> >
> > Agradesco de antemano por su ayuda.
> >
> >
> > Gabriel Antonio Trujillo Paucar
> > Estudiante de Biologia
> > 997603768
> > ________________________________
> > > Date: Thu, 24 Jan 2013 07:40:08 +0000
> > > From: evapcastro@yahoo.es<http://mc/compose?to=evapcastro%40yahoo.es>
> > > Subject: Re: [R-es] Ayuda con el bucle if
> > > To:
> > jorgeivanvelez@gmail.com<http://mc/compose?to=jorgeivanvelez%40gmail.com
> >;
> > gabriel_enter@hotmail.com<
> http://mc/compose?to=gabriel_enter%40hotmail.com>
> > > CC: r-help-es@r-project.org<
> http://mc/compose?to=r-help-es%40r-project.org>
> > >
> > > Hola Gabriel,
> > >
> > > Después del "else" tiene que ir una asignación o un bloque, pero no
> > > puede ir directamente una condición, sin precederlo de un "if".
> > >
> > > Adapta tu ejemplo a esta estructura:
> > >
> > > if (a==1){
> > > b=2
> > > }else{if (a==2){
> > > b=3}
> > > }
> > >
> > > Es un modo de hacerlo.
> > >
> > > Saludos.
> > >
> > > --- El jue, 24/1/13, Gabriel Trujillo Paucar
> > >
> > <gabriel_enter@hotmail.com<
> http://mc/compose?to=gabriel_enter%40hotmail.com>>
> > escribió:
> > >
> > > De: Gabriel Trujillo Paucar
> > <gabriel_enter@hotmail.com<
> http://mc/compose?to=gabriel_enter%40hotmail.com>>
> > > Asunto: [R-es] Ayuda con el bucle if
> > > Para:
> > jorgeivanvelez@gmail.com<http://mc/compose?to=jorgeivanvelez%40gmail.com
> >
> > > CC:
> > "r-help-es@r-project.org<http://mc/compose?to=r-help-es%40r-project.org
> >"
> > <r-help-es@r-project.org<http://mc/compose?to=r-help-es%40r-project.org
> >>
> > > Fecha: jueves, 24 de enero, 2013 06:20
> > >
> > >
> > > Saludos nuevamente, estaba encontrando otra forma para poder encontrar
> > > la solucion al problema que escribi anteriormente y creo que la
> > > encontre solo que tengo un problema con el bucle if. Tengo un marco de
> > > datos como sigue:
> > >
> > > ######################################
> > >
> > >
> MIBpa=data.frame(M1=c(1,1,0),row.names=c("MGAS-001","MGAS-002","MGAS-003"))
> > >
> > > #########################################
> > >
> > > y he generado un bucle if
> > >
> > > ##################
> > >
> > >
> >
> if(as.numeric(match("MGAS-001",row.names(MIBpa)))==1||as.numeric(match("MGAS-002",row.names(MIBpa)))==1){
> > > Coc2=3}
> > > else
> > >
> >
> (as.numeric(match("MGAS-001",row.names(MIBpa)))==0||as.numeric(match("MGAS-002",row.names(MIBpa)))==0){
> > > Coc2=0}
> > >
> > > #######################
> > >
> > > Para que me dos resultados distintos (un "3" si se da la primera
> > > situacion y un "0" si se da la segunda) pero cuando corro el bucle me
> > > sale
> > > el siguiente mensaje:
> > >
> > > Error: inesperado 'else' en "else"
> > >
> > > NO se en que me estoy equivocando
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > Gabriel Antonio Trujillo Paucar
> > > Estudiante de Biologia
> > > 997603768
> > >
> > >
> > >
> > > _______________________________________________
> > > R-help-es mailing list
> > >
> > R-help-es@r-project.org<http://mc/compose?to=R-help-es%40r-project.org
> ><http:///mc/compose?to=R-help-es%40r-project.org>
> > > https://stat.ethz.ch/mailman/listinfo/r-help-es
> > >
> >
> >
> _______________________________________________
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>
>


-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es

	[[alternative HTML version deleted]]

