[R] different types graphs
Jim Lemon
jim at bitwrit.com.au
Thu Feb 25 10:47:48 CET 2010
On 02/25/2010 07:48 PM, chinna wrote:
>
>> library(RODBC)
>> ch<- odbcConnect("durga")
>> sqlQuery(ch, paste("SELECT * from emp"))
>> sqlQuery(ch, ("SELECT * from xyz"))
>
> store revenue year_y
> 1 bigbazar 787875 2008
> 2 more 87876 2008
>
> plot(revenue ~ year_y, data=xyz, pch=16)
>
>
> can i get any diffrent types of graphs like pie charts, bar plots.using plot
> commands?
>
Hi chinna,
You can get all of these and more. What type of plot you want depends
upon what you want to illustrate:
# scatterplot - sprays all the values out with a
# different color for each store
plot(xyz$year_y,xyz$revenue,type="p",
col=as.numeric(xyz$store))
# barplot - shows you the relative positions of
# the stores in different years
# this example was done with the toy data I posted last time
barplot(as.matrix(
reshape(xyz,idvar="Store",timevar="Year",dir="wide")[,2:4])
,beside=TRUE)
legend(8,600000,levels(xyz$Store),fill=c("gray80","gray50","gray20"))
# pie chart - shows the mean revenue for each store
# over all the years sampled - again the previous toy data
pie(by(xyz$Revenue,xyz$Store,mean))
You have to decide on what you want to illustrate unless you are just
producing PlotArt, a new genre in which the artist produces random plots
of financial data to emphasize the meaninglessness of the materialistic
culture in which we pretend that we are happy, but
No, I can't keep a straight face anymore.
Jim
More information about the R-help
mailing list