Hi
r-help-bounces at r-project.org napsal dne 05.01.2011 01:26:42:
>
> Hi
>
> Suppose you have the code below. The result I get from the cat function
is> from the avgs object. Now, I have 30 diferent objects like this and I
wish
I would stick to list and do not make 30 objects
a.g. avg.width from avgs object can be extracted by
as.numeric(unlist(sapply(avgs, function(x) x[4])))[-1]
Regards
Petr
> to make a summary table, something like:
>
> Avgs1 Avgs2
> Avgs3
>
> i= 2 average= 0.515983i i= 2 average= 0.746983 i= 2
> average= 0.2665983
> i= 3 average= 0.5135953 i= 3 average= 0.7345953 i= 3
> average= 0.23455953
> i= 4 average= 0.4998128 i= 4 average= 0.7233128 i= 4
> average= 0.21398128
>
>
> > library(cluster)
> > d<-hclust(dist(iris[,-5]))
> >
> > avgs<-sapply(1:20,function(x)
> + summary(silhouette(cutree(d,x),
> + dist(iris[,-5]))))
> > # str(avgs)
> >
>
> > # print out the average widths
> > for (i in 2:length(avgs)){ # ignore first item
> + cat('i=', i, 'average=', avgs[[i]]$avg.width,
'\n')
> + }
> i= 2 average= 0.515983
> i= 3 average= 0.5135953
> i= 4 average= 0.4998128
> i= 5 average= 0.346174
> i= 6 average= 0.3382031
> i= 7 average= 0.3297649
> i= 8 average= 0.324025
> i= 9 average= 0.3191681
> i= 10 average= 0.3028503
> i= 11 average= 0.3072648
> i= 12 average= 0.2834498
> i= 13 average= 0.2776717
> i= 14 average= 0.2855396
> i= 15 average= 0.2745142
> i= 16 average= 0.2578903
> i= 17 average= 0.2531909
> i= 18 average= 0.2473504
> i= 19 average= 0.2484205
> i= 20 average= 0.2545357
>
>
> thanks
> A.Dias
> --
> View this message in context:
http://r.789695.n4.nabble.com/List-to-a-summary-> table-tp3174698p3174698.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.