[R] table data as input to the function

Jim Lemon jim at bitwrit.com.au
Wed Feb 24 07:38:52 CET 2010

On 02/24/2010 04:30 PM, chinna wrote:
> sorry for asking again and again
> my Requirement:
> i am connecting to teradata database and i am accessing tables and table
> data also, i need generate graphs using that data and also i need  to
> forecast the results.
> for example
> i have a table xyz
> Store      Year       Revenue
> abc         2010       $557889
> def          2010       $697356
> i want to draw a barplot and i want to forecast the results  of revenue for
> next year
> can u please tell me wheather this is possible or not?
> if possible give me the suggestions.
> (graphs in the sense using some business intelligence tools like
> cognos,business objects using that tools we are generating graphs for
> analysing  sales information of retail stores and graphs generation.)

Hi chinna,
Drawing a barplot is relatively easy, as there are quite a few functions 
apart from plain old "barplot" that will give you a lot of options. Here 
is a candy-colored example using barNest in the plotrix package:

  main="Revenue by store and year",

The forecasting part could be as simple as:

abc.lm<-lm(Revenue~Year,xyz[xyz$Store == "abc",])

and then use the coefficient for Year to provide a linear estimate of 
the succeeding year(s). For the toy data I generated, I estimated that 
store abc would make a loss of $94554 in 2010.

If you want more than a simple linear predictor, just use a different 


More information about the R-help mailing list