Can't figure this out. I have the following list of salary averages per
year, per position. The dput output is:
> dput(salaries)
structure(list(yearID = c(2009, 2009, 2009, 2009, 2009, 2009,
2009, 2009, 2009, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008,
2008), AVG = c(8956855.61, 7886684.166126, 7534048.43102, 7406439.339471,
7219148.437934, 6697734.908336, 6400379.88398, 3765720.093796,
3630731.367928, 9022895.226432, 8441165.305623, 8102876.628756,
7797941.00885, 7407822.844814, 7293419.165284, 6429637.71541,
4946563.641848, 4233392.0256), POS = c("RF", "3B",
"LF", "DH",
"1B", "SS", "CF", "2B", "C",
"DH", "RF", "3B", "1B", "SS",
"CF",
"LF", "C", "2B")), .Names = c("yearID",
"AVG", "POS"), row.names = c("1",
"2", "3", "4", "5", "6",
"7", "8", "9", "10", "11",
"12", "13",
"14", "15", "16", "17", "18"),
class = "data.frame")
I am trying to render a stacked bar chart, on the X axis the list of unique
positions, on the Y axis the range of min to max salary. The stacked charts
would show the averages per year, with a color unique to each year.'
Trying something like:
barplot(t(salaries), main='Position', ylab='Y',
col=heat.colors(2), space=0.1, cex.axis=0.8, las=1,
names.arg=salaries$POS, cex=0.8
)
Corollary: what's the easiest way to format currency in R? e..g make the Y
axis read "$55,008.00" instead of 55008.00.
Any tips? Thanks!
--
Wells Oliver
wells@submute.net
[[alternative HTML version deleted]]