<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Pessoal,<br>
    <br>
           Estava utilizando a rotina desenvolvida pelo Éder e vi que
    ela criava os contrastes, mas não um desenho fatorial completo como
    quando uso a função gen.factorial() do pacote AlgDesign, alguém
    poderia me dizer como a partir da rotina do Éder eu poderia criar
    isso, uma vez que, não posso utilizar a função gen.factorial()
    diretamente porque em meus dados verdadeiros eu tenho dados
    desbalanceados. Meu código é: <br>
    <br>
    #Fator<br>
    treat <- gl(4, 15, labels = paste("t", 1:4, sep="")); treat <br>
    <br>
    #Comparações<br>
    TI    <- model.matrix(~ treat-1)<br>
    head(TI)<br>
    <br>
    f <- nlevels(treat)<br>
    comb <- t(combn(1:f, 2))<br>
    n    <- nrow(comb)<br>
    <br>
    contr2 <- NULL<br>
    for (x in 1:n) {<br>
          i <- comb[x, 1]<br>
          j <- comb[x, 2]<br>
          tmp <- list(TI[,i] - TI[,j]); names(tmp) <-
    paste0("TI",i, "_", j)<br>
           contr2 <- c(contr2, tmp) }<br>
    contr2df <- as.data.frame(contr2)<br>
    contr2df <br>
    <br>
    #Equivalente, mas criando um desenho fatorial completo<br>
    require(AlgDesign)<br>
    contr2df2 <-AlgDesign::gen.factorial(3, 6, TRUE,
    varNames=c("TI1_2", "TI1_3", "TI1_4", "TI2_3", "TI2_4", "TI3_4"))<br>
    contr2df2<br>
    #<br>
    <br>
    Obrigado,<br>
    <pre class="moz-signature" cols="72">-- 
======================================================================
Alexandre dos Santos
Proteção Florestal 
IFMT - Instituto Federal de Educação, Ciência e Tecnologia de Mato Grosso
Campus Cáceres
Caixa Postal 244
Avenida dos Ramires, s/n
Bairro: Distrito Industrial 
Cáceres - MT                      CEP: 78.200-000
Fone: (+55) 65 8132-8112 (TIM)   (+55) 65 9686-6970 (VIVO)
<a class="moz-txt-link-abbreviated" href="mailto:e-mails:alexandresantosbr@yahoo.com.br">e-mails:alexandresantosbr@yahoo.com.br</a> 
        <a class="moz-txt-link-abbreviated" href="mailto:alexandre.santos@cas.ifmt.edu.br">alexandre.santos@cas.ifmt.edu.br</a> 
Lattes: <a class="moz-txt-link-freetext" href="http://lattes.cnpq.br/1360403201088680">http://lattes.cnpq.br/1360403201088680</a>
OrcID: orcid.org/0000-0001-8232-6722 
Researchgate: <a class="moz-txt-link-freetext" href="https://www.researchgate.net/profile/Alexandre_Santos10">https://www.researchgate.net/profile/Alexandre_Santos10</a>                       
LinkedIn: <a class="moz-txt-link-freetext" href="https://br.linkedin.com/in/alexandre-dos-santos-87961635">https://br.linkedin.com/in/alexandre-dos-santos-87961635</a>
======================================================================
</pre>
    <div class="moz-cite-prefix">Em 10/03/2016 08:33, ASANTOS escreveu:<br>
    </div>
    <blockquote cite="mid:56E169AC.80900@yahoo.com.br" type="cite">
      <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
      Muito obrigado Éder!!!!<br>
      <br>
             Era exatamente a função que eu procurava, funcionou
      perfeitamente,<br>
      <br>
      Abraços,<br>
      <pre class="moz-signature" cols="72">-- 
======================================================================
Alexandre dos Santos
Proteção Florestal 
IFMT - Instituto Federal de Educação, Ciência e Tecnologia de Mato Grosso
Campus Cáceres
Caixa Postal 244
Avenida dos Ramires, s/n
Bairro: Distrito Industrial 
Cáceres - MT                      CEP: 78.200-000
Fone: (+55) 65 8132-8112 (TIM)   (+55) 65 9686-6970 (VIVO)
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:e-mails:alexandresantosbr@yahoo.com.br">e-mails:alexandresantosbr@yahoo.com.br</a> 
        <a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:alexandre.santos@cas.ifmt.edu.br">alexandre.santos@cas.ifmt.edu.br</a> 
Lattes: <a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lattes.cnpq.br/1360403201088680">http://lattes.cnpq.br/1360403201088680</a>
OrcID: orcid.org/0000-0001-8232-6722 
Researchgate: <a moz-do-not-send="true" class="moz-txt-link-freetext" href="https://www.researchgate.net/profile/Alexandre_Santos10">https://www.researchgate.net/profile/Alexandre_Santos10</a>                       
LinkedIn: <a moz-do-not-send="true" class="moz-txt-link-freetext" href="https://br.linkedin.com/in/alexandre-dos-santos-87961635">https://br.linkedin.com/in/alexandre-dos-santos-87961635</a>
======================================================================
</pre>
      <div class="moz-cite-prefix">Em 09/03/2016 17:39, Éder Comunello
        escreveu:<br>
      </div>
      <blockquote
cite="mid:CABmC8gkVd9cycjGrbSibCLKxNfdRztF1qUiiQ=NPON5xaWRTUQ@mail.gmail.com"
        type="cite">
        <div dir="ltr">
          <div class="gmail_default"
            style="font-family:verdana,sans-serif">Alexandre, boa tarde!</div>
          <div class="gmail_default"
            style="font-family:verdana,sans-serif"><br>
          </div>
          <div class="gmail_default"
            style="font-family:verdana,sans-serif">Não sei se entendi
            direito, mas fiz uma tentativa. Se a ideia servir dá pra
            colocar na forma de uma função.</div>
          <div class="gmail_default"
            style="font-family:verdana,sans-serif"><br>
          </div>
          <div class="gmail_default"
            style="font-family:verdana,sans-serif"><br>
          </div>
          <div class="gmail_default" style="">
            <div class="gmail_default"><font face="monospace, monospace">###

                <code r></font></div>
            <div class="gmail_default"><font face="monospace, monospace">treat

                <- gl(4, 15, labels = paste("t", 1:4, sep="")); treat
                # Fatores</font></div>
            <div class="gmail_default"><font face="monospace, monospace"><br>
              </font></div>
            <div class="gmail_default"><font face="monospace, monospace">#
                Variables</font></div>
            <div class="gmail_default"><font face="monospace, monospace">set.sed(124)</font></div>
            <div class="gmail_default"><font face="monospace, monospace">sp

                 <- cbind(c(rnorm(10,  5, 0.25), rnorm(50, 2.5,
                0.25)), rnorm(60, 2.5, 0.25),</font></div>
            <div class="gmail_default"><font face="monospace, monospace"> 
                           c(rnorm(10, 12, 0.25), rnorm(50, 2.5, 0.25)),
                rnorm(60, 2.5, 0.25))</font></div>
            <div class="gmail_default"><font face="monospace, monospace">colnames(sp)

                <- c("sp1", "sp2", "sp3", "sp4")</font></div>
            <div class="gmail_default"><font face="monospace, monospace">head(sp)</font></div>
            <div class="gmail_default"><font face="monospace, monospace"><br>
              </font></div>
            <div class="gmail_default"><font face="monospace, monospace">#Criação

                da matriz de contrastes </font></div>
            <div class="gmail_default"><font face="monospace, monospace">TI

                   <- model.matrix(~ treat-1)</font></div>
            <div class="gmail_default"><font face="monospace, monospace">head(TI)</font></div>
            <div class="gmail_default"><font face="monospace, monospace"><br>
              </font></div>
            <div class="gmail_default"><font face="monospace, monospace">f
                   <- length(levels(treat))</font></div>
            <div class="gmail_default"><font face="monospace, monospace">comb

                <- t(combn(1:f, 2))</font></div>
            <div class="gmail_default"><font face="monospace, monospace">n
                   <- nrow(comb)</font></div>
            <div class="gmail_default"><font face="monospace, monospace"><br>
              </font></div>
            <div class="gmail_default"><font face="monospace, monospace">contr2

                <- NULL</font></div>
            <div class="gmail_default"><font face="monospace, monospace">for

                (x in 1:n) {</font></div>
            <div class="gmail_default"><font face="monospace, monospace"> 
                   i <- comb[x, 1]</font></div>
            <div class="gmail_default"><font face="monospace, monospace"> 
                   j <- comb[x, 2]</font></div>
            <div class="gmail_default"><font face="monospace, monospace"> 
                   tmp <- list(TI[,i] - TI[,j]); names(tmp) <-
                paste0("TI",i, "_", j)</font></div>
            <div class="gmail_default"><font face="monospace, monospace"> 
                   contr2 <- c(contr2, tmp)</font></div>
            <div class="gmail_default"><font face="monospace, monospace">}</font></div>
            <div class="gmail_default"><font face="monospace, monospace">contr2</font></div>
            <div class="gmail_default"><font face="monospace, monospace"><br>
              </font></div>
            <div class="gmail_default"><font face="monospace, monospace">head(do.call(cbind,

                contr2))</font></div>
            <div class="gmail_default"><font face="monospace, monospace">#
                  TI1_2 TI1_3 TI1_4 TI2_3 TI2_4 TI3_4</font></div>
            <div class="gmail_default"><font face="monospace, monospace">#
                1     1     1     1     0     0     0</font></div>
            <div class="gmail_default"><font face="monospace, monospace">#
                2     1     1     1     0     0     0</font></div>
            <div class="gmail_default"><font face="monospace, monospace">#
                3     1     1     1     0     0     0</font></div>
            <div class="gmail_default"><font face="monospace, monospace">#
                4     1     1     1     0     0     0</font></div>
            <div class="gmail_default"><font face="monospace, monospace">#
                5     1     1     1     0     0     0</font></div>
            <div class="gmail_default"><font face="monospace, monospace">#
                6     1     1     1     0     0     0</font></div>
            <div class="gmail_default"><font face="monospace, monospace">###

                </code></font></div>
          </div>
          <div class="gmail_extra"><font face="monospace, monospace"><br>
            </font></div>
          <div class="gmail_extra"><br clear="all">
            <div>
              <div class="gmail_signature">
                <div dir="ltr">
                  <div>
                    <div dir="ltr">
                      <div>
                        <div dir="ltr">
                          <div>
                            <div dir="ltr"><font style="font-size:small"
                                face="arial, helvetica, sans-serif">
                                <div style="font-family:'trebuchet
                                  ms',sans-serif;display:inline">​</div>
                              </font><font style="font-size:12.8px"
                                face="arial, helvetica, sans-serif"><span
                                  style="font-size:small">================================================</span><br>
                                Éder Comunello</font>
                              <div style="font-size:12.8px"><span
                                  style="font-family:arial,helvetica,sans-serif">Agronomist

                                  (UEM), MSc in Environ. Sciences (UEM)</span><font
                                  face="arial, helvetica, sans-serif"><br>
                                </font></div>
                              <div style="font-size:12.8px">
                                <div style="font-size:small"><span
                                    style="font-family:arial,helvetica,sans-serif">DSc

                                    in Agricultural Systems
                                    Engineering (USP/Esalq)</span><br>
                                </div>
                                <div><span style="font-size:small">Brazilian

                                    Agricultural Research Corporation (</span><font
                                    style="font-size:small" face="arial,
                                    helvetica, sans-serif">Embrapa)</font></div>
                                <div>
                                  <div><font style="font-size:small"
                                      face="arial, helvetica,
                                      sans-serif">Dourados, MS, Brazil </font><font
                                      size="2" face="arial, helvetica,
                                      sans-serif">|<O>|</font></div>
                                  <div style="font-size:small"><span
                                      style="font-family:arial,helvetica,sans-serif">================================================</span><br>
                                  </div>
                                </div>
                              </div>
                              <div style="font-size:small"><font
                                  face="arial, helvetica, sans-serif">GEO, </font>-22.2752,

                                -54.8182, 408m<span
                                  style="font-family:arial,helvetica,sans-serif"><br>
                                </span></div>
                              <div style="font-size:12.8px"><span
                                  style="font-size:small;font-family:arial,helvetica,sans-serif">UTC-04:00

                                  / DST: UTC-03:00</span></div>
                              <div>
                                <div>
                                  <div><br>
                                  </div>
                                  <div><br>
                                  </div>
                                </div>
                                <div style="font-size:small"><br>
                                </div>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <br>
        <fieldset class="mimeAttachmentHeader"></fieldset>
        <br>
        <pre wrap="">_______________________________________________
R-br mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:R-br@listas.c3sl.ufpr.br">R-br@listas.c3sl.ufpr.br</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br">https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br</a>
Leia o guia de postagem (<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.leg.ufpr.br/r-br-guia">http://www.leg.ufpr.br/r-br-guia</a>) e forne�a c�digo m�nimo reproduz�vel.</pre>
      </blockquote>
      <br>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
R-br mailing list
<a class="moz-txt-link-abbreviated" href="mailto:R-br@listas.c3sl.ufpr.br">R-br@listas.c3sl.ufpr.br</a>
<a class="moz-txt-link-freetext" href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br">https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br</a>
Leia o guia de postagem (<a class="moz-txt-link-freetext" href="http://www.leg.ufpr.br/r-br-guia">http://www.leg.ufpr.br/r-br-guia</a>) e forne�a c�digo m�nimo reproduz�vel.</pre>
    </blockquote>
    <br>
  </body>
</html>