Hello List, The question is how to plot a bar chart in which bars are sorted in ascending order for each level of X. I would appreciate receiving your advice and help.
Thanks,
Pradip Muhuri
******
The following codes work when producing the chart in which bars are NOT sorted.
Please see the output.
***** Data File
5.1 8.7 1.6
3.7 7.4 2.8
10.4 12.0 3.5
4.4 8.8 1.7
2.0 3.5 0.7
6.7 11.0 3.1
5.3 6.7 1.8
###############
#source("C:/Documents and Settings/pradip.muhuri/My
Documents/disorders_chart1.R") - Please ignore this line
#R Scripts for bar chart begin here
# Read drug data from tab-delimited data set
drug_data <- read.table("C:/Documents and Settings/pradip.muhuri/My
Documents/xdrug.dat", header=FALSE,
col.names=c("Age_1217", "Age_1825", "Age_26Plus"),
row.names = c("White","Black","Native American/Alaska
Native","Hawaiian/OPI","Asian", "More than One Race", "Hispanic"),
sep="\t")
# Graph drug use disorder data with adjacent bars using rainbow colors
barplot(as.matrix(drug_data), main="Past-Year Illicit Drug Use Disorders by
Race/Ethnicity", ylab= "Past-Year Use Disorder Rate (%)", beside=TRUE,
col=rainbow(7))
legend("topright", c("White","Black","Native American/Alaska
Native","Hawaiian/OPI","Asian", "More than One Race", "Hispanic"), cex=0.6,
bty="n", fill=rainbow(7));
Bar_Graph.pdf
Description: Bar_Graph.pdf
______________________________________________ [email protected] 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.

