<html><body><div style="color:#000; background-color:#fff; font-family:Courier New, courier, monaco, monospace, sans-serif;font-size:12px"><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr"><span id="yui_3_16_0_1_1421690433290_2895">Pessoal, preciso de uma ajuda...</span></div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr"><span><br></span></div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr"><span id="yui_3_16_0_1_1421690433290_3227">Meus dados são esses "a21", nele tenho a observação de 219 vacas (n_vaca), que estão numeradas de maneira aleatória. As vacas foram separadas em 3 grupos, onde em cada grupo aplicaram um tratamento diferente. Esse tratamento foi aplicado em forma de injeções (17 injeções) e entre uma injeção e outra, temos 14 dias de intervalo. A variável de interesse é "producao"</span></div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">> head(a21)</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style=""> n_vaca n_lactacao trat pri_multiparas n_injecao dia_ciclo dia_exp producao saude</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">8 1731 3 1 2 0 1 -13 45.1 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">9 1731 3 1 2 0 2 -12 47.8 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">10 1731 3 1 2 0 3 -11 45.5 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">11 1731 3 1 2 0 4 -10 45.2 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">12 1731 3 1 2 0 5 -9 47.4 enrollment</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">13 1731 3 1 2 0 6 -8 48.3 enrollment</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style=""><br></div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style=""># Aqui estou criando um subconjunto, onde tenho todas as informações da vaca 1731:</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">> (vaca1731<- subset(a21, a21$n_vaca==1731)); dim(vaca1731)</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style=""> n_vaca n_lactacao trat pri_multiparas n_injecao dia_ciclo dia_exp producao saude</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">8 1731 3 1 2 0 1 -13 45.1 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">9 1731 3 1 2 0 2 -12 47.8 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">10 1731 3 1 2 0 3 -11 45.5 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">11 1731 3 1 2 0 4 -10 45.2 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">12 1731 3 1 2 0 5 -9 47.4 enrollment</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">13 1731 3 1 2 0 6 -8 48.3 enrollment</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">14 1731 3 1 2 0 7 -7 46.4 enrollment</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">15 1731 3 1 2 0 8 -6 47.9 enrollment</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">16 1731 3 1 2 0 9 -5 50.3 enrollment</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">17 1731 3 1 2 0 10 -4 50.8 enrollment</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">18 1731 3 1 2 0 11 -3 47.9 enrollment</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">19 1731 3 1 2 0 12 -2 46.2 heat</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">20 1731 3 1 2 0 13 -1 50.8 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">21 1731 3 1 2 0 14 0 45.8 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">22 1731 3 1 2 1 1 1 50.5 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">23 1731 3 1 2 1 2 2 49.0 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">24 1731 3 1 2 1 3 3 48.8 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">25 1731 3 1 2 1 4 4 53.9 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">26 1731 3 1 2 1 5 5 45.4 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">27 1731 3 1 2 1 6 6 38.6 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">28 1731 3 1 2 1 7 7 41.3 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">29 1731 3 1 2 1 8 8 50.2 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">30 1731 3 1 2 1 9 9 50.2 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">31 1731 3 1 2 1 10 10 50.4 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">32 1731 3 1 2 1 11 11 49.9 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">33 1731 3 1 2 1 12 12 50.1 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">34 1731 3 1 2 1 13 13 52.0 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">35 1731 3 1 2 1 14 14 47.8 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">36 1731 3 1 2 2 1 15 50.0 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">37 1731 3 1 2 2 2 16 49.7 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">38 1731 3 1 2 2 3 17 50.4 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">39 1731 3 1 2 2 4 18 48.9 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">40 1731 3 1 2 2 5 19 49.5 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">41 1731 3 1 2 2 6 20 48.8 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">42 1731 3 1 2 2 7 21 56.3 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">43 1731 3 1 2 2 8 22 52.1 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">44 1731 3 1 2 2 9 23 51.6 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">45 1731 3 1 2 2 10 24 50.5 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">46 1731 3 1 2 2 11 25 46.0 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">47 1731 3 1 2 2 12 26 53.7 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">48 1731 3 1 2 2 13 27 51.7 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">49 1731 3 1 2 2 14 28 49.1 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">50 1731 3 1 2 3 1 29 51.9 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">51 1731 3 1 2 3 2 30 51.4 healthy</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">...</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">256 1731 3 1 2 17 11 235 21.2 lamness</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">257 1731 3 1 2 17 12 236 19.4 lamness</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">258 1731 3 1 2 17 13 237 23.5 lamness</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">259 1731 3 1 2 17 14 238 19.9 lamness</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">[1] 251 9</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style=""><br></div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style=""><br></div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style=""># Para simplificar, considere que temos apenas 10 vacas:</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">#--------------------------------------------</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">> vacas <- c(1731, 2090, 2652, 2945, 2946, 3246, 3413, 3593, 3878, 3882) # é a numeração das vacas</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style=""><br></div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style=""># O que eu quero fazer com esses dados é o seguinte:</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">v1<- subset(a21, a21$n_vaca==vacas[1]); dim(v1)<br></div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">v2<- subset(a21, a21$n_vaca==vacas[2]); dim(v2)</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">v3<- subset(a21, a21$n_vaca==vacas[3]); dim(v3)</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">v4<- subset(a21, a21$n_vaca==vacas[4]); dim(v4)</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">v5<- subset(a21, a21$n_vaca==vacas[5]); dim(v5)</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">v6<- subset(a21, a21$n_vaca==vacas[6]); dim(v6)</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">v7<- subset(a21, a21$n_vaca==vacas[7]); dim(v7)</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">v8<- subset(a21, a21$n_vaca==vacas[8]); dim(v8)</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">v9<- subset(a21, a21$n_vaca==vacas[9]); dim(v9)</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">v10<- subset(a21, a21$n_vaca==vacas[10]); dim(v10)</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style=""><br class="" style=""></div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">b<- c(</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">tapply(v1$producao, v1$dia_ciclo, mean),</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">tapply(v2$producao, v2$dia_ciclo, mean),</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">tapply(v3$producao, v3$dia_ciclo, mean),</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">tapply(v4$producao, v4$dia_ciclo, mean),</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">tapply(v5$producao, v5$dia_ciclo, mean),</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">tapply(v6$producao, v6$dia_ciclo, mean),</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">tapply(v7$producao, v7$dia_ciclo, mean),</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">tapply(v8$producao, v8$dia_ciclo, mean),</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">tapply(v9$producao, v9$dia_ciclo, mean),</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">tapply(v10$producao, v10$dia_ciclo, mean))</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">#--------------------------------------------</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style=""><br></div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">Ainda estou engatinhando em questão de programação no R, como poderia fazer um looping com essas linhas de comando, pois preciso fazer isso para as 219 vacas!</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style=""><br></div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">desde já, muito obrigada!</div><div id="yui_3_16_0_1_1421690433290_2806" dir="ltr" class="" style="">Simone</div><div></div><div id="yui_3_16_0_1_1421690433290_2807"> </div><div class="signature" id="yui_3_16_0_1_1421690433290_2812"><div id="yui_3_16_0_1_1421690433290_2811"><i id="yui_3_16_0_1_1421690433290_2810"><b id="yui_3_16_0_1_1421690433290_2809"><font size="3" face="times new roman, new york, times, serif" id="yui_3_16_0_1_1421690433290_2808">***---***---***---***---***---***---***---***---***---***---***---***---***</font></b></i></div><div style="background-color:transparent;font-style:normal;font-family:'times new roman', 'new york', times, serif;color:rgb(0, 0, 0);font-size:3px;font-weight:bold;" id="yui_3_16_0_1_1421690433290_2816"><i id="yui_3_16_0_1_1421690433290_2815"><b id="yui_3_16_0_1_1421690433290_2814"><font size="3" face="times new roman, new york, times, serif" id="yui_3_16_0_1_1421690433290_2813">* Simone Daniela Sartorio</font></b></i></div><div id="yui_3_16_0_1_1421690433290_2817"><font face="times new roman, new york, times, serif" id="yui_3_16_0_1_1421690433290_2818">* <span class="Apple-tab-span" style="white-space:pre;"> </span>Professora Adjunta I no CCA/UFSCar, Araras/SP.</font></div><div id="yui_3_16_0_1_1421690433290_2820"><font face="times new roman, new york, times, serif" id="yui_3_16_0_1_1421690433290_2819">*<span class="Apple-tab-span" style="white-space:pre;"> </span>Doutora e Mestre em Estatística e Experimentação Agronômica - ESALQ/USP.</font></div><div id="yui_3_16_0_1_1421690433290_2857"><font face="times new roman, new york, times, serif" id="yui_3_16_0_1_1421690433290_2859">* <span class="Apple-tab-span" style="white-space:pre;"> </span>Licenciada em Matemática - UNESP/Rio Claro.</font></div><div id="yui_3_16_0_1_1421690433290_2858"><b id="yui_3_16_0_1_1421690433290_2872" style="font-family: 'times new roman', 'new york', times, serif; font-size: 13px; line-height: 1.22; background-color: transparent;"><i id="yui_3_16_0_1_1421690433290_2871"><font size="3" face="Times New Roman" id="yui_3_16_0_1_1421690433290_2870">***---***---***---***---***---***---***---***---***---***---***---***---***</font></i></b><br></div><div style="background-color:transparent;font-style:normal;font-family:'Times New Roman';color:rgb(0, 0, 0);font-size:3px;font-weight:bold;" id="yui_3_16_0_1_1421690433290_2955"><b id="yui_3_16_0_1_1421690433290_2954"><font size="3" face="Times New Roman"><font color="#bf00bf" size="1"><span style="font-family:'times new roman';"><i></i></span></font></font><div id="yui_3_16_0_1_1421690433290_2953"><font size="3" face="Times New Roman" id="yui_3_16_0_1_1421690433290_2952"><i id="yui_3_16_0_1_1421690433290_2951"><span class="tab" id="yui_3_16_0_1_1421690433290_2950"><span class="tab" id="yui_3_16_0_1_1421690433290_2949"><var id="yui-ie-cursor"></var> <span class="tab" id="yui_3_16_0_1_1421690433290_2948"> <span class="tab" id="yui_3_16_0_1_1421690433290_2947"> <span class="tab" id="yui_3_16_0_1_1421690433290_2946"> <span class="tab" id="yui_3_16_0_1_1421690433290_2945"> <span class="tab" id="yui_3_16_0_1_1421690433290_2944"> <span class="tab" id="yui_3_16_0_1_1421690433290_2943"> <span class="tab" id="yui_3_16_0_1_1421690433290_2942"> <span class="tab" id="yui_3_16_0_1_1421690433290_2941"> <span class="tab" id="yui_3_16_0_1_1421690433290_2940"> <span class="tab" id="yui_3_16_0_1_1421690433290_2939"> <span class="tab" id="yui_3_16_0_1_1421690433290_2938"> <span class="tab" id="yui_3_16_0_1_1421690433290_2937"> <span class="tab" id="yui_3_16_0_1_1421690433290_2936"> <span class="tab"> <span class="tab"> <span class="tab"> <span class="tab"> <span class="tab"> <span class="tab"> <span class="tab"> <span class="tab"> </span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>Tenha um bom dia! </i><font face="Courier New, courier, monaco, monospace, sans-serif">;)</font></font></div></b></div></div></div></body></html>