<html><head></head><body><div style="color:#000; background-color:#fff; font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:13px"><div id="yui_3_16_0_ym19_1_1502903380287_6331" dir="ltr"># Suponha o sequinte experimento em blocos ao acaso<br id="yui_3_16_0_ym19_1_1502903380287_6476"># com tamanho da parcela experimental de 4 plantas<br id="yui_3_16_0_ym19_1_1502903380287_6477"># no qual se conta o número pulpas ninfas e ovos.<br id="yui_3_16_0_ym19_1_1502903380287_6478"><br id="yui_3_16_0_ym19_1_1502903380287_6479"># GOSTARIA DE OBTER O CONJUNTO DE DADOS QUE FOSSE A SOMA DE PLANTAS POR CULTIVAR BLOCOS,<br id="yui_3_16_0_ym19_1_1502903380287_6480"># QUANDO USO TODO CONJUNTO DE DADOS FUNCIONA BEM<br id="yui_3_16_0_ym19_1_1502903380287_6481"><br id="yui_3_16_0_ym19_1_1502903380287_6482"><br id="yui_3_16_0_ym19_1_1502903380287_6483"><br id="yui_3_16_0_ym19_1_1502903380287_6484">require(reshape)<br id="yui_3_16_0_ym19_1_1502903380287_6485"> <br id="yui_3_16_0_ym19_1_1502903380287_6486"><br id="yui_3_16_0_ym19_1_1502903380287_6487">x<-factor(LETTERS[1:3])<br id="yui_3_16_0_ym19_1_1502903380287_6488">cultivar<-rep(x, each=6)<br id="yui_3_16_0_ym19_1_1502903380287_6489">bloco<-rep(1:2,each=3)<br id="yui_3_16_0_ym19_1_1502903380287_6490">planta<-rep(1:3)<br id="yui_3_16_0_ym19_1_1502903380287_6491"> <br id="yui_3_16_0_ym19_1_1502903380287_6492">ninfa<-c(0,0,0,1,1,1,0,0,0,1,2,3,0,1,2,0,0,1)<br id="yui_3_16_0_ym19_1_1502903380287_6493">pulpa<-c(1,0,1,1,0,1,0,0,0,0,0,0,0,2,1,0,0,4)<br id="yui_3_16_0_ym19_1_1502903380287_6494">ovos<-c(2,2,0,3,0,0,0,0,4,0,0,0,0,2,0,0,0,0)<br id="yui_3_16_0_ym19_1_1502903380287_6495"><br id="yui_3_16_0_ym19_1_1502903380287_6496">df<-data.frame(cultivar, bloco, planta, ninfa, pulpa, ovos)<br id="yui_3_16_0_ym19_1_1502903380287_6497"><br id="yui_3_16_0_ym19_1_1502903380287_6498"><br id="yui_3_16_0_ym19_1_1502903380287_6499">df.m<-melt(df, id=c("cultivar","bloco","planta"))<br id="yui_3_16_0_ym19_1_1502903380287_6500">df.m<br id="yui_3_16_0_ym19_1_1502903380287_6501"><br id="yui_3_16_0_ym19_1_1502903380287_6502">df.c<-cast(df.m, cultivar + bloco ~ variable, sum, na.rm=TRUE )<br id="yui_3_16_0_ym19_1_1502903380287_6503">df.c<br id="yui_3_16_0_ym19_1_1502903380287_6504"><br id="yui_3_16_0_ym19_1_1502903380287_6505"># MAS QUANDO SELECIONO SÓ UMA PARTE<br id="yui_3_16_0_ym19_1_1502903380287_6506"># OS VALORES NÃO BATEM COM O QUADRO ANTERIOR, ALGUEM SABERIA EXPLICAR ????<br id="yui_3_16_0_ym19_1_1502903380287_6507">df.c1<-cast(df.m, cultivar + bloco ~ variable, subset=variable==c("ninfa","pulpa"), sum)<br id="yui_3_16_0_ym19_1_1502903380287_6508">df.c1<br id="yui_3_16_0_ym19_1_1502903380287_6509"><br id="yui_3_16_0_ym19_1_1502903380287_6510"># a SOMA DE ninfa e pulpa tambem esta errada<br id="yui_3_16_0_ym19_1_1502903380287_6511">df.c0<-cast(df.m, cultivar + bloco ~ ., subset=variable==c("ninfa","pulpa"), sum)<br id="yui_3_16_0_ym19_1_1502903380287_6512">df.c0<br id="yui_3_16_0_ym19_1_1502903380287_6513"><br id="yui_3_16_0_ym19_1_1502903380287_6514"> <br id="yui_3_16_0_ym19_1_1502903380287_6515">Att</div><div dir="ltr" id="yui_3_16_0_ym19_1_1502903380287_6524">Antonio W Moita</div><div dir="ltr">Embrapa Hortaliças<br></div></div></body></html>