Ya puestos, hay otras formas: 1. función aggregate(): aggregate( Lon ~ Año, data = talla, mean)
2. sqldf library(sqldf) sqldf("select avg(Lon) as med_lon from tall group by Año") Saludos, Carlos Ortega www.qualityexcellence.es El 28 de agosto de 2018, 2:27, Eric <ericconchamu...@gmail.com> escribió: > Con la libreria data.table: > > as.data.table(tus.datos) > > tus.datos[, mean(Long), by=Año] > > Suerte !!! > > eric. > > > > > > On 27/08/18 19:23, Carlos Ortega wrote: > >> Hola, >> >> Puedes hacerlo de muchas formas, pero por seguir lo que más se utiliza >> últimamente de "dplyr"... >> >> library(dplyr) >> my_res <- talla %>% >> group_by(Año) %>% >> summarise( val_avg = mean(Long), n = n()) >> my_res >> >> >> Saludos, >> Carlos Ortega >> www.qualiytexcellence.es >> >> >> El 27 de agosto de 2018, 23:19, MAURICIO MARDONES < >> mauricio.mardo...@ifop.cl >> >>> escribió: >>> Estimada lista >>> >>> la pregunta es muy básica, pero necesito saber la Long media para cada >>> año. >>> Estoy pillando en el bucle. >>> >>> head(talla) >>>> >>> X Long Año >>> 1 1 56 2016 >>> 2 2 58 2016 >>> 3 3 58 2016 >>> 4 4 58 2016 >>> 5 5 58 2016 >>> 6 6 58 2016 >>> >>>> tail(talla) >>>> >>> X Long Año >>> 2567630 2567630 86 2000 >>> 2567631 2567631 88 2000 >>> 2567632 2567632 88 2000 >>> 2567633 2567633 88 2000 >>> 2567634 2567634 89 2000 >>> 2567635 2567635 95 2000 >>> >>> agradecería! >>> >>> Saludos >>> >>> -- >>> >>> *Mauricio Mardones Inostroza* >>> >>> Investigador Departamento Evaluación de Recursos >>> Instituto de Fomento Pesquero - IFOP >>> Valparaíso - Chile >>> +56-32-2151442 >>> >>> www.ifop.cl >>> >>> -- >>> C*ertificación ISO 9001/2008*: Sistema de Datos >>> Biológico-Pesqueros (Arica, >>> Iquique, Coquimbo, Valparaíso, San Antonio, Talcahuano y Calbuco, >>> pesquerías industriales y artesanales) >>> >>> [[alternative HTML version deleted]] >>> >>> _______________________________________________ >>> R-help-es mailing list >>> R-help-es@r-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]] _______________________________________________ R-help-es mailing list R-help-es@r-project.org https://stat.ethz.ch/mailman/listinfo/r-help-es