Try this:

lapply(l, function(x)median(x[,sapply(x, is.numeric)]))

On Fri, Nov 7, 2008 at 8:42 AM, Ptit_Bleu <ptit_bleu@yahoo.fr> wrote:

>
> Hello,
>
> I have a list of data.frame
> rowsplit : List of 15
>  $ (0,0.025]   :'data.frame':   169 obs. of  7 variables:
>  $ (0.025,0.05]:'data.frame':   174 obs. of  7 variables:
>  $ (0.05,0.075]:'data.frame':   92 obs. of  7 variables:
>  $ (0.075,0.1] :'data.frame':   76 obs. of  7 variables:
>  $ (0.1,0.125] :'data.frame':   37 obs. of  7 variables:
>  $ (0.125,0.15]:'data.frame':   32 obs. of  7 variables:
>  $ (0.15,0.175]:'data.frame':   45 obs. of  7 variables:
>  $ (0.175,0.2] :'data.frame':   56 obs. of  7 variables:
>  $ (0.2,0.225] :'data.frame':   36 obs. of  7 variables:
>  $ (0.225,0.25]:'data.frame':   47 obs. of  7 variables:
>  $ (0.25,0.275]:'data.frame':   34 obs. of  7 variables:
>  $ (0.275,0.3] :'data.frame':   43 obs. of  7 variables:
>  $ (0.3,0.325] :'data.frame':   29 obs. of  7 variables:
>  $ (0.325,0.35]:'data.frame':   29 obs. of  7 variables:
>  $ (0.35,0.375]:'data.frame':   17 obs. of  7 variables:
>
> And I would like to get a data.frame gathering the median value of each
> variable for each intervall.
> as.data.frame(t(sapply(rowsplit, mean)) works well but I would prefer to
> use
> median but with sapply(rowsplit, median), I get the following message
> "Error
> in median.default(X[[1L]], ...) : need numeric data".
>
> Any idea ?
>
> Thanks in advance for your help,
> Have a nice week-end,
> Ptit Bleu.
>
> PS :I'm under XP and use R2.7.2.
> --
> View this message in context:
> http://www.nabble.com/sapply-and-median%2C-possible-or-not---tp20378222p20378222.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

	[[alternative HTML version deleted]]

