Gracias!! investigando encontré el paquete doBy y con la función summary
muy parecida al proc summary de SAS

Os pongo la r-help:
Function to calculate groupwise summary statisticsDescription

Function to calculate groupwise summary statistics, much like the summary
procedure of SAS
Usage

summaryBy(formula, data = parent.frame(), id = NULL, FUN = mean,
          keep.names=FALSE, p2d=FALSE, order=TRUE, full.dimension=FALSE, ...)

Argumentsformula

A formula object, see examples below
data

A data frame
id

A formula specifying variables which data are not grouped by but which
should appear in the output. See examples below.
FUN

A list of functions to be applied, see examples below.
keep.names

If TRUE and if there is only ONE function in FUN, then the variables in the
output will have the same name as the variables in the input, see
'examples'.
p2d

Should parentheses in output variable names be replaced by dots?
order

Should the resulting dataframe be ordered according to the variables on the
right hand side of the formula? (using orderBy <../../doBy/help/orderBy>
full.dimension

If TRUE then rows of summary statistics are repeated such that the result
will have the same number of rows as the input dataset.
...

Additional arguments to FUN. This could for example be NA actions.
*
*

Saludos!

El 21 de enero de 2012 19:48, Jorge I Velez <jorgeivanvelez@gmail.com>escribió:

> Hola Otto,
>
> SI, si es posible:  bastaria con crear una funcion que lo hiciera.  A
> continuacion un ejemplo:
>
> aggregate(. ~ Species, data = iris, function(x) c(M = mean(x), Var =
> var(x)))
>
> Por cierto, podrias reducir
>
> divisasBE$USD <-as.numeric(as.character(divisasBE$USD))
> divisasBE$JPY <-as.numeric(as.character(divisasBE$JPY))
> divisasBE$CHF <-as.numeric(as.character(divisasBE$CHF))
> ...
> divisasBE$BRR <-as.numeric(as.character(divisasBE$BRR))
>
> utilizando algo como
>
> divisisasBE[] <- apply(divisasBE, 2, function(x)
> as.numeric(as.character(x)))
>
> antes de crear divisasBE$date o inclusive agregando na.strings = "" cuando
> lees la base de datos via read.delim(). Dale una mirada a ?read.delim para
> mas opciones.
>
> Un saludo,
> Jorge.-
>
>
> 2012/1/21 Otto F. Wagner <>
>
>>  Hola!  muchas gracias a Carlos, Jorge y Oscar. Al final tardé más de la
>> cuenta porque mis datos tenían valores NA. Tuve que usar la opción de
>> aggregate "na.rm=TRUE" para que al calcular la media saltara esos valores
>> y
>> los valores agregados no fueran NA.
>>
>> Quiero compartir el código por si algún novato como yo se encuentra en
>> situación similar. Una pregunta: hay alguna forma en aggregate para que te
>> calcule dos funciones a la vez? por ejemplo Var y Mean.
>>
>> Gracias y saludos!
>>
>> El código:
>>
>> divisasBE <- read.delim("~/investigacion/Divisas/divisasBE.txt", dec=".")
>>
>> # como hay datos nulos R los pasa a factor, luego debemos convertirlos a
>> numéricos
>> divisasBE$date<-as.Date(divisasBE$date)
>> #class(divisasBE$CHF)
>> divisasBE$USD <-as.numeric(as.character(divisasBE$USD))
>> divisasBE$JPY <-as.numeric(as.character(divisasBE$JPY))
>> divisasBE$CHF <-as.numeric(as.character(divisasBE$CHF))
>> divisasBE$GBP <-as.numeric(as.character(divisasBE$GBP))
>> divisasBE$SUK <-as.numeric(as.character(divisasBE$SUK))
>> divisasBE$DEK <-as.numeric(as.character(divisasBE$DEK))
>> divisasBE$NOK <-as.numeric(as.character(divisasBE$NOK))
>> divisasBE$AUD <-as.numeric(as.character(divisasBE$AUD))
>> divisasBE$CAD <-as.numeric(as.character(divisasBE$CAD))
>> divisasBE$NED <-as.numeric(as.character(divisasBE$NED))
>> divisasBE$SDR <-as.numeric(as.character(divisasBE$SDR))
>> divisasBE$CHP <-as.numeric(as.character(divisasBE$CHP))
>> divisasBE$CGK <-as.numeric(as.character(divisasBE$CGK))
>> divisasBE$HUF <-as.numeric(as.character(divisasBE$HUF))
>> divisasBE$POZ <-as.numeric(as.character(divisasBE$POZ))
>> divisasBE$ESK <-as.numeric(as.character(divisasBE$ESK))
>> divisasBE$ESC <-as.numeric(as.character(divisasBE$ESC))
>> divisasBE$ISK <-as.numeric(as.character(divisasBE$ISK))
>> divisasBE$LEL <-as.numeric(as.character(divisasBE$LEL))
>> divisasBE$RUL <-as.numeric(as.character(divisasBE$RUL))
>> divisasBE$BUL <-as.numeric(as.character(divisasBE$BUL))
>> divisasBE$INR <-as.numeric(as.character(divisasBE$INR))
>> divisasBE$TUL <-as.numeric(as.character(divisasBE$TUL))
>> divisasBE$LIL <-as.numeric(as.character(divisasBE$LIL))
>> divisasBE$HKD <-as.numeric(as.character(divisasBE$HKD))
>> divisasBE$SID <-as.numeric(as.character(divisasBE$SID))
>> divisasBE$SUR <-as.numeric(as.character(divisasBE$SUR))
>> divisasBE$SUW <-as.numeric(as.character(divisasBE$SUW))
>> divisasBE$CHY <-as.numeric(as.character(divisasBE$CHY))
>> divisasBE$CRK <-as.numeric(as.character(divisasBE$CRK))
>> divisasBE$INDR<-as.numeric(as.character(divisasBE$IND))
>> divisasBE$MAR <-as.numeric(as.character(divisasBE$MAR))
>> divisasBE$FIP <-as.numeric(as.character(divisasBE$FIP))
>> divisasBE$RUR <-as.numeric(as.character(divisasBE$RUR))
>> divisasBE$TEB <-as.numeric(as.character(divisasBE$TEB))
>> divisasBE$MEP <-as.numeric(as.character(divisasBE$MEP))
>> divisasBE$BRR <-as.numeric(as.character(divisasBE$BRR))
>> divisasBE$mo <- substr(divisasBE$date,6,7)
>> divisasBE$yr <- substr(divisasBE$date, 1,4)
>> divisasBE$month<-paste('01-',divisasBE$mo,'-',divisasBE$yr,sep='')
>> divisasBE$month<-as.Date(divisasBE$month,  "%d-%m-%Y" )
>>
>>
>>
>>
>> #agregamos, para poder "vencer" los NA usamos na.rm=TRUE
>>
>> eur.agg<-aggregate(divisasBE,
>> by=list(divisasBE$month),FUN=mean,na.rm=TRUE)
>>  eur.agg$date<-eur.agg$Group.1
>> eur.agg$Group.1<-NULL
>> eur.agg$mo<-NULL
>> eur.agg$yr<-NULL
>> eur.agg$month<-NULL
>>
>> *
>> *
>>
>>
>>
>> El 19 de enero de 2012 23:28, Otto F. Wagner <> escribió:
>>
>> > Gracias a ambos!!
>> >
>> > El problema fue que aggregate no clasifica por variables tipo date, pero
>> > se convierte a string y va bien.
>> >
>> >
>> > Intenté el sqldf pero creo que me daba error por nombrar las tablas de
>> la
>> > forma algo.algo.
>> >
>> > Un saludo
>> >
>> >
>> > El 19 de enero de 2012 23:00, Carlos Ortega <>escribió:
>>
>> >
>> > Hola,
>> >>
>> >> Con la librería sqldf es bastante inmediato:
>> >>
>> >>
>> >> Lines <- "DeployID Date.Time LocationQuality Latitude Longitude
>> >> STM05-1 2005/02/28 17:35 Good -35.562 177.158
>> >> STM05-1 2005/02/28 19:44 Good -35.487 177.129
>> >> STM05-1 2005/02/28 23:01 Unknown -35.399 177.064
>> >> STM05-1 2005/03/01 07:28 Unknown -34.978 177.268
>> >> STM05-1 2005/03/01 18:06 Poor -34.799 177.027
>> >> STM05-1 2005/03/01 18:47 Poor -34.85 177.059
>> >> STM05-2 2005/02/28 12:49 Good -35.928 177.328
>> >> STM05-2 2005/02/28 21:23 Poor -35.926 177.314
>> >> "
>> >>
>> >> DF <- read.table(textConnection(Lines), skip = 1,  as.is = TRUE,
>> >>  col.names = c("Id", "Date", "Time", "Quality", "Lat", "Long"))
>> >>
>> >> > sqldf("select Date, avg(Lat), avg(Long) from DF group by Date")
>>    Date  avg(Lat) avg(Long)
>> >> 1 2005/02/28 -35.66040  177.1986
>> >> 2 2005/03/01 -34.87567  177.1180
>> >>
>> >>  >
>> >> Al margen queda el sinsentido de la media de una Longitud o Latitud...
>> >> :-).
>> >>
>> >> Saludos,
>> >> Carlos Ortega
>> >> www.qualityexcellence.es
>> >>
>> >>
>> >> Saludos,
>> >> Carlos Ortega
>> >> www.qualityexcellence
>> >>
>> >> El 19 de enero de 2012 22:26, Otto F. Wagner <>escribió:
>>
>> >>
>> >>> *Hola!!! resulta que tengo unos datos de divisas ordenados por fechas
>> >>>
>> >>> (días) los que he convertido a formato tipo YYYY-MM-DD donde DD
>> siempre
>> >>> es
>> >>> 01:*
>> >>> *
>> >>> *
>> >>>
>> >>> *
>> >>> EUR.resto$date<-as.Date(EUR.resto$date)
>> >>>
>> >>> EUR.resto$mo <- substr(EUR.resto$date,6,7)
>> >>> EUR.resto$yr <- substr(EUR.resto$date, 1,4)
>> >>>
>> >>>
>> >>> EUR.resto$month<-paste('01-',EUR.resto$mo,'-',EUR.resto$yr,sep='')
>> >>> EUR.resto$month<-as.Date(EUR.resto$month)
>> >>>
>> >>>
>> >>> ahora necesito agrupar mis datos por mes-años (01-mes-año) y obtener
>> su
>> >>> valor medio.  En SAS haría un proc summary donde obtendría una nueva
>> >>> tabla
>> >>> con menos registros ya que estarían agrupados por mes.  Que función
>> en R
>> >>> puedo usar equivalente a esta?
>> >>>
>> >>> Si uso: eur.agg<-aggregate(EUR.resto$Yenes.japoneses.por.Euro,
>> >>> by=list(EUR.resto$month),FUN=mean) me da error.
>> >>>
>> >>> Gracias por vuestra ayuda,
>> >>>
>> >>> un saludo,
>> >>>
>> >>> Otto
>> >>> *
>> >>>
>> >>>        [[alternative HTML version deleted]]
>> >>>
>> >>>
>> >>> _______________________________________________
>> >>> R-help-es mailing list
>> >>> R-help-es@r-project.org
>> >>> https://stat.ethz.ch/mailman/listinfo/r-help-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
>>
>>
>

	[[alternative HTML version deleted]]

