<div dir="ltr">Valeu Elias<div><br></div><div style>Seu CRM funcionou  perfeitamente</div><div style>Testei com todos os niveis, apenas fiz este ajuste, pois no valores limites estavam classificando errado:</div><div style>
<br></div><div style><div>cfosf <- rbind(c(10.001, 20.001, 30.001, 45.001), c(6.61, 12.01, 20.01, 30.01),</div><div>               c(4.01, 8.01, 12.01, 18.01), c(2.71, 5.41, 8.01, 12.01))</div><div>c=escada(x, y, c(15.001, 35.001, 60.001), cfosf)</div>
<div><br></div><div style>Como a gente coloca Resolvido?</div><div style><br></div><div style>Abraço</div><div style><br></div><div style>Hélio</div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">Em 20 de maio de 2013 15:16, Elias Krainski [via R-br] <span dir="ltr"><<a href="mailto:ml-node+s2285057n4659361h59@n4.nabble.com" target="_blank">ml-node+s2285057n4659361h59@n4.nabble.com</a>></span> escreveu:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

        
  
    
  
  
    <div>Porque em vez de usar esse tipo escada de classificação você
      não usa um tipo suave? Para mim, este último faz mais sentido.
      Veja exemplo de como obter isso com a sua 'escada':<br>
      <br>
      ### Tabela da quinta aproximação <br>
      ###     Nível de Fósforo mg/dm3<br>
      ###Argila%    muito baixo         Baixo    Médio    Bom    Muito
      Bom<br>
      ###60-100    <2.7(menor e igual)    2.8-5.4    5.5-8   
      8.1-12    >12<br>
      ###35-60    <4                    4.1-8    8.1-12    12.1-18   
      >18<br>
      ###15-35    <6.6                    6.7-12    12.1-20   
      20.1-30    >30<br>
      ### 0-15    <10                    10.1-20    20.1-30   
      30.1-45    >45<br>
      <br>
      escada <- function(x, y, <a href="http://x.br" target="_blank">x.br</a>, <a href="http://y.br" target="_blank">y.br</a>, ...) { <br>
        ix <- findInterval(x, <a href="http://x.br" target="_blank">x.br</a>, ...)+1<br>
        lr <- lapply(1:nrow(<a href="http://y.br" target="_blank">y.br</a>), function(j) {<br>
          i <- which(ix==j)<br>
          list(i=i, r=findInterval(y[i], <a href="http://y.br" target="_blank">y.br</a>[j,], ...)+1)<br>
        })<br>
        i <- sort(unlist(lapply(lr, function(x) x$i)), <br>
                  index.return=TRUE, method='quick')$ix<br>
        unlist(lapply(lr, function(x) x$r))[i]<br>
      }<br>
      <br>
      ### exemplo simulado<br>
      n <- 30000<br>
      x <- 90*runif(n)<br>
      y <- runif(n, 0, 100-x)*.7<br>
      <br>
      cfosf <- rbind(c(10, 20, 30, 45), c(6.6, 12, 20, 30),<br>
                     c(4, 8, 12, 18), c(2.7, 5.4, 8, 12))<br>
      cfosf<br>
      res <- escada(x, y, c(15, 35, 60), cfosf)<br>
      table(res)<br>
      <br>
      plot(x, y, col=res, pch=19, las=1, asp=1, cex=0.3, <br>
           xlab="Argila", ylab="Fósforo")<br>
      abline(v=c(15, 35, 60), col=gray(.7))<br>
      for (j in 1:nrow(cfosf))<br>
        segments(c(0, 15, 35, 60)[j], cfosf[j,],<br>
                 c(15, 35, 60, 100)[j], cfosf[j,], lty=3)<br>
      legend("topright", c("Muito baixo", "Baixo", "Médio", "Muito
      bom"),<br>
             pch=19, col=1:5, bty='n', title='Textura')<br>
      segments(0,100,100,0, lty=3)<br>
      <br>
      ### usando esses dados simulados<br>
      ### (ideal e' usar dados reais)<br>
      ### para obter uma funcao suave <br>
      <br>
      require(MASS)<br>
      aj <- polr(resp ~ x*y, data.frame(resp=factor(res,
      ordered=TRUE)))<br>
      <br>
      prd <- predict(aj)<br>
      <br>
      plot(x, y, col=unclass(prd), pch=19, las=1, asp=1, cex=0.3, <br>
           xlab="Argila", ylab="Fósforo")<br>
      legend("topright", c("Muito baixo", "Baixo", "Médio", "Muito
      bom"),<br>
             pch=19, col=1:5, bty='n', title='Textura')<br>
      <br>
      ### classificando um novo solo (Argila=36, fosforo=19)<br>
      ### usando a escada:<br>
      escada(36, 19, c(15, 35, 60), cfosf)<br>
      ### suave:<br>
      predict(aj, newdata=data.frame(x=36, y=19)) <br>
      <br>
      <br>
      Att.<br>
      Elias.<br>
       <br>
    </div><div><div class="h5">
    <blockquote style="border-left:2px solid #cccccc;padding:0 1em" type="cite">
      <hr style="border-top:1px solid #ccc">
      <div>Em 18/05/2013 09:28, <strong>Hélio Gallo Rocha <
          <a href="http://user/SendEmail.jtp?type=node&node=4659361&i=0" rel="nofollow" link="external" target="_blank">[hidden email]</a> ></strong> escreveu:</div>
      <div dir="ltr">Bom dia a todos,
        <div> </div>
        <div>Para recomendar adubação fosfatada é necessário classificar
          a quantidade de fósforo da análise em conjunto a textura do
          solo.</div>
        <div> </div>
        <div>
          <table style="border-collapse:collapse;width:311pt" border="0" cellpadding="0" cellspacing="0" width="412">
            <colgroup><col style="width:48pt" width="64"> <col style="width:96pt" width="128"> <col style="width:38pt" span="3" width="50"> <col style="width:53pt" width="70"> </colgroup>
            <tbody>
              <tr style="min-height:12.75pt">
                <td style="min-height:12.75pt;width:48pt" height="17" width="64"> Tabela da quinta aproximação 
                  <table style="width:311pt;margin-left:3pt;border-collapse:collapse" border="0" cellpadding="0" cellspacing="0" width="415">
                    <tbody>
                      <tr style="min-height:12.75pt">
                        <td style="width:48pt;border:1pt solid windowtext;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="64">
                          <p><span style="font-size:10pt;font-family:Arial"> </span></p>
                        </td>
                        <td style="width:263pt;border-style:solid solid solid none;border-top-color:windowtext;border-right-color:windowtext;border-bottom-color:windowtext;border-top-width:1pt;border-right-width:1pt;border-bottom-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" colspan="5" nowrap valign="bottom" width="351">

                          <p style="text-align:center" align="center"><span style="font-size:10pt;font-family:Arial">Nível de Fósforo mg/dm3</span></p>
                        </td>
                      </tr>
                      <tr style="min-height:12.75pt">
                        <td style="width:48pt;border-style:none solid solid;border-right-color:windowtext;border-bottom-color:windowtext;border-left-color:windowtext;border-right-width:1pt;border-bottom-width:1pt;border-left-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="64">

                          <p><span style="font-size:10pt;font-family:Arial">Argila%</span></p>
                        </td>
                        <td style="width:97.7pt;border-style:none solid solid none;border-bottom-color:windowtext;border-bottom-width:1pt;border-right-color:windowtext;border-right-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="130">

                          <p><span style="font-size:10pt;font-family:Arial">muito baixo</span></p>
                        </td>
                        <td style="width:37.6pt;border-style:none solid solid none;border-bottom-color:windowtext;border-bottom-width:1pt;border-right-color:windowtext;border-right-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="50">

                          <p><span style="font-size:10pt;font-family:Arial">Baixo</span></p>
                        </td>
                        <td style="width:37.6pt;border-style:none solid solid none;border-bottom-color:windowtext;border-bottom-width:1pt;border-right-color:windowtext;border-right-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="50">

                          <p><span style="font-size:10pt;font-family:Arial">Médio</span></p>
                        </td>
                        <td style="width:37.6pt;border-style:none solid solid none;border-bottom-color:windowtext;border-bottom-width:1pt;border-right-color:windowtext;border-right-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="50">

                          <p><span style="font-size:10pt;font-family:Arial">Bom</span></p>
                        </td>
                        <td style="width:52.5pt;border-style:none solid solid none;border-bottom-color:windowtext;border-bottom-width:1pt;border-right-color:windowtext;border-right-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="70">

                          <p><span style="font-size:10pt;font-family:Arial">Muito Bom</span></p>
                        </td>
                      </tr>
                      <tr style="min-height:12.75pt">
                        <td style="width:48pt;border-style:none solid solid;border-right-color:windowtext;border-bottom-color:windowtext;border-left-color:windowtext;border-right-width:1pt;border-bottom-width:1pt;border-left-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="64">

                          <p><span style="font-size:10pt;font-family:Arial">60-100</span></p>
                        </td>
                        <td style="width:97.7pt;border-style:none solid solid none;border-bottom-color:windowtext;border-bottom-width:1pt;border-right-color:windowtext;border-right-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="130">

                          <p><span style="font-size:10pt;font-family:Arial"><2.7 (menor e igual)</span></p>
                        </td>
                        <td style="width:37.6pt;border-style:none solid solid none;border-bottom-color:windowtext;border-bottom-width:1pt;border-right-color:windowtext;border-right-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="50">

                          <p><span style="font-size:10pt;font-family:Arial">2.8-5.4</span></p>
                        </td>
                        <td style="width:37.6pt;border-style:none solid solid none;border-bottom-color:windowtext;border-bottom-width:1pt;border-right-color:windowtext;border-right-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="50">

                          <p><span style="font-size:10pt;font-family:Arial">5.5-8</span></p>
                        </td>
                        <td style="width:37.6pt;border-style:none solid solid none;border-bottom-color:windowtext;border-bottom-width:1pt;border-right-color:windowtext;border-right-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="50">

                          <p><span style="font-size:10pt;font-family:Arial">8.1-12</span></p>
                        </td>
                        <td style="width:52.5pt;border-style:none solid solid none;border-bottom-color:windowtext;border-bottom-width:1pt;border-right-color:windowtext;border-right-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="70">

                          <p><span style="font-size:10pt;font-family:Arial">>12</span></p>
                        </td>
                      </tr>
                      <tr style="min-height:12.75pt">
                        <td style="width:48pt;border-style:none solid solid;border-right-color:windowtext;border-bottom-color:windowtext;border-left-color:windowtext;border-right-width:1pt;border-bottom-width:1pt;border-left-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="64">

                          <p><span style="font-size:10pt;font-family:Arial">35-60</span></p>
                        </td>
                        <td style="width:97.7pt;border-style:none solid solid none;border-bottom-color:windowtext;border-bottom-width:1pt;border-right-color:windowtext;border-right-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="130">

                          <p><span style="font-size:10pt;font-family:Arial"><4</span></p>
                        </td>
                        <td style="width:37.6pt;border-style:none solid solid none;border-bottom-color:windowtext;border-bottom-width:1pt;border-right-color:windowtext;border-right-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="50">

                          <p><span style="font-size:10pt;font-family:Arial">4.1-8</span></p>
                        </td>
                        <td style="width:37.6pt;border-style:none solid solid none;border-bottom-color:windowtext;border-bottom-width:1pt;border-right-color:windowtext;border-right-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="50">

                          <p><span style="font-size:10pt;font-family:Arial">8.1-12</span></p>
                        </td>
                        <td style="width:37.6pt;border-style:none solid solid none;border-bottom-color:windowtext;border-bottom-width:1pt;border-right-color:windowtext;border-right-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="50">

                          <p><span style="font-size:10pt;font-family:Arial">12.1-18</span></p>
                        </td>
                        <td style="width:52.5pt;border-style:none solid solid none;border-bottom-color:windowtext;border-bottom-width:1pt;border-right-color:windowtext;border-right-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="70">

                          <p><span style="font-size:10pt;font-family:Arial">>18</span></p>
                        </td>
                      </tr>
                      <tr style="min-height:12.75pt">
                        <td style="width:48pt;border-style:none solid solid;border-right-color:windowtext;border-bottom-color:windowtext;border-left-color:windowtext;border-right-width:1pt;border-bottom-width:1pt;border-left-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="64">

                          <p><span style="font-size:10pt;font-family:Arial">15-35</span></p>
                        </td>
                        <td style="width:97.7pt;border-style:none solid solid none;border-bottom-color:windowtext;border-bottom-width:1pt;border-right-color:windowtext;border-right-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="130">

                          <p><span style="font-size:10pt;font-family:Arial"><6.6</span></p>
                        </td>
                        <td style="width:37.6pt;border-style:none solid solid none;border-bottom-color:windowtext;border-bottom-width:1pt;border-right-color:windowtext;border-right-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="50">

                          <p><span style="font-size:10pt;font-family:Arial">6.7-12</span></p>
                        </td>
                        <td style="width:37.6pt;border-style:none solid solid none;border-bottom-color:windowtext;border-bottom-width:1pt;border-right-color:windowtext;border-right-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="50">

                          <p><span style="font-size:10pt;font-family:Arial">12.1-20</span></p>
                        </td>
                        <td style="width:37.6pt;border-style:none solid solid none;border-bottom-color:windowtext;border-bottom-width:1pt;border-right-color:windowtext;border-right-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="50">

                          <p><span style="font-size:10pt;font-family:Arial">20.1-30</span></p>
                        </td>
                        <td style="width:52.5pt;border-style:none solid solid none;border-bottom-color:windowtext;border-bottom-width:1pt;border-right-color:windowtext;border-right-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="70">

                          <p><span style="font-size:10pt;font-family:Arial">>30</span></p>
                        </td>
                      </tr>
                      <tr style="min-height:12.75pt">
                        <td style="width:48pt;border-style:none solid solid;border-right-color:windowtext;border-bottom-color:windowtext;border-left-color:windowtext;border-right-width:1pt;border-bottom-width:1pt;border-left-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="64">

                          <p><span style="font-size:10pt;font-family:Arial">0-15</span></p>
                        </td>
                        <td style="width:97.7pt;border-style:none solid solid none;border-bottom-color:windowtext;border-bottom-width:1pt;border-right-color:windowtext;border-right-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="130">

                          <p><span style="font-size:10pt;font-family:Arial"><10</span></p>
                        </td>
                        <td style="width:37.6pt;border-style:none solid solid none;border-bottom-color:windowtext;border-bottom-width:1pt;border-right-color:windowtext;border-right-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="50">

                          <p><span style="font-size:10pt;font-family:Arial">10.1-20</span></p>
                        </td>
                        <td style="width:37.6pt;border-style:none solid solid none;border-bottom-color:windowtext;border-bottom-width:1pt;border-right-color:windowtext;border-right-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="50">

                          <p><span style="font-size:10pt;font-family:Arial">20.1-30</span></p>
                        </td>
                        <td style="width:37.6pt;border-style:none solid solid none;border-bottom-color:windowtext;border-bottom-width:1pt;border-right-color:windowtext;border-right-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="50">

                          <p><span style="font-size:10pt;font-family:Arial">30.1-45</span></p>
                        </td>
                        <td style="width:52.5pt;border-style:none solid solid none;border-bottom-color:windowtext;border-bottom-width:1pt;border-right-color:windowtext;border-right-width:1pt;padding:0cm 3.5pt;min-height:12.75pt" nowrap valign="bottom" width="70">

                          <p><span style="font-size:10pt;font-family:Arial">>45</span></p>
                        </td>
                      </tr>
                    </tbody>
                  </table>
                </td>
                <td style="border-left-style:none;width:263pt" colspan="5" width="348"> </td>
              </tr>
            </tbody>
          </table>
        </div>
        <div>
          <div> </div>
          <div> </div>
          <div>Fiz o seguinte:</div>
          <div>
            <div>solo=c(1:50)                       # resultado da
              análise do solo</div>
            <div>argila=c(60,35,15,0)            # teor de argila</div>
            <div>p1=c(0,2.7,5.4,8,12)             # fósforo com + de 60%
              de argila</div>
            <div>p2=c(0,4,8,12,18)                # fósforo com 35 a
               60% de argila</div>
            <div>p3=c(0,6.6,12,20,30)            # fósforo com 15 a  35%
              de argila</div>
            <div>p4=c(0,10,20,30,45)            # fósforo com < 15%
              de argila</div>
            <div>res=c("Muito.Baixo","Baixo", "Medio", "Alto",
              "Muito.alto")</div>
            <div> </div>
            <div>Assim se o resultado de P é 3.5 :</div>
            <div>60% de arg, seria classificado como Baixo</div>
            <div>35% de arg. seria classificado como muito baixo</div>
            <div> </div>
            <div>andei dando uma olhada na solução do post </div>
            <h1 style="font-family:GillSans,Trebuchet,Calibri,Arial,sans-serif;color:#333333;font-size:1.8em;margin:0.25em 0px 0.8em">Uso
              do ifelse</h1>
            <div> </div>
          </div>
          <div>A saida desta função seria casada com uma recomendação,</div>
          <div> </div>
          <div>Grato a todos</div>
          <div> </div>
          -- <br>
          Hélio Gallo Rocha<br>
          IFSULDEMINAS - Câmpus Muzambinho</div>
      </div>
      <div> </div>
      <br>
      <fieldset></fieldset>
      <br>
      <pre>_______________________________________________
R-br mailing list
<a href="http://user/SendEmail.jtp?type=node&node=4659361&i=1" rel="nofollow" link="external" target="_blank">[hidden email]</a>
<a href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br" rel="nofollow" link="external" target="_blank">https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br</a>
Leia o guia de postagem (<a href="http://www.leg.ufpr.br/r-br-guia" rel="nofollow" link="external" target="_blank">http://www.leg.ufpr.br/r-br-guia</a>) e forneça código mínimo reproduzível.</pre>
    </blockquote>
    <br>
  

<br>_______________________________________________
<br>R-br mailing list
<br><a href="http://user/SendEmail.jtp?type=node&node=4659361&i=2" rel="nofollow" link="external" target="_blank">[hidden email]</a>
<br><a href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br" rel="nofollow" link="external" target="_blank">https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br</a><br>Leia o guia de postagem (<a href="http://www.leg.ufpr.br/r-br-guia" rel="nofollow" link="external" target="_blank">http://www.leg.ufpr.br/r-br-guia</a>) e forneça código mínimo reproduzível.

        
        
        
        <br>
        <br>
        <hr noshade size="1" color="#cccccc">
        </div></div><div style="color:#444;font:12px tahoma,geneva,helvetica,arial,sans-serif"><div><div class="h5">
                <div style="font-weight:bold">If you reply to this email, your message will be added to the discussion below:</div>
                </div></div><a href="http://r-br.2285057.n4.nabble.com/R-br-Classificar-fosforo-e-textura-do-solo-tp4659355p4659361.html" target="_blank">http://r-br.2285057.n4.nabble.com/R-br-Classificar-fosforo-e-textura-do-solo-tp4659355p4659361.html</a>
        </div><div class="HOEnZb"><div class="h5">
        <div style="color:#666;font:11px tahoma,geneva,helvetica,arial,sans-serif;margin-top:.4em;line-height:1.5em">
                
                To unsubscribe from R-br, <a href="http://r-br.2285057.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3357982&code=aGVsaW9nYWxsb3JvY2hhQGdtYWlsLmNvbXwzMzU3OTgyfC0xMzQ3NTkwMDY4" target="_blank">click here</a>.<br>

                <a href="http://r-br.2285057.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml" rel="nofollow" style="font:9px serif" target="_blank">NAML</a>
        </div></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Hélio Gallo Rocha<br>IFSULDEMINAS - Câmpus Muzambinho<br>
</div>