[S] Summary: ordered barplots

Steve Friedman (friedman@gis.umn.edu)
Fri, 8 May 1998 08:49:30 -0500


All of these work well

1) where tmp is the matrix

barplot(tmp[1,order(tmp[1,])],names=dimnames(tmp)[[2]][order(tmp[1,])])

2) Try the "order()" function:

cnames <- dimnames(matrix)[[2]]
ord <- order(matrix[1,])
barplot(matrix[1,ord],names=cnames[ord])

3) barplot.row <- function(i, X) {

# plot row i of matrix X in sorted order, with column names as labels.

bar.names <- dimnames(X)[[2]]
o <- order(X[i, ])
barplot(X[i, o], names = bar.names[o])
}

> barplot.row(3,x)

Thanks to all who came up with staight forward and niffty solutions.

Steve Friedman
Dept. Forest Resources
115 Green Hall
University of Minnesota

-- 

----------------------------------------------------------------------- This message was distributed by s-news@wubios.wustl.edu. To unsubscribe send e-mail to s-news-request@wubios.wustl.edu with the BODY of the message: unsubscribe s-news