Writing a function in a corrrect way

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Writing a function in a corrrect way

Ashis Deb
Hi  all  ,  I   am  about  to  make   a  package  using   gWidgets  and
RGTK,   so  for that  I  had  put all  my  codes  into  a  empty  function
to  access  it afterward by the function name  using   like    trade()   .
Here is the  below  code  example :---



trade<-function()   <<<<  --------------------------------HERE   IS  THE
EMPTY   FUNCTION


   {



  library(RGtk2)

library(gWidgets)

 library(gWidgets2)

library(gWidgetsRGtk2)

 library(FuzzyToolkitUoN)

 library(splines)

 library(plyr)

library(Cairo)

  library(cairoDevice)

 library(e1071)

  library(quantmod)

 library(TTR)


 library(xts)


#main GUI code
win=gwindow(" PREDICTIVE TRADER ",visible=FALSE)




group<-ggroup(cont=win)

left_group<-ggroup(cont=group,horizontal=FALSE)


right_group<-ggroup(cont=group,horizontal=FALSE)





frame<-gframe("widgets",cont=left_group,expand=TRUE)

size(frame)<-c(400,450)

tbl=glayout(cont=frame)



tbl[7,1]= gbutton("BUYANDSELLSIGNALS ",cont=tbl,handler=BSS)

tbl[5,1]=glabel("ENTER SYMBOL:-",cont=tbl)

tbl[5,2]<-gedit(""  , cont=tbl,coerce.with=as.character)


tbl[11,1]<-glabel("ENTER PROFIT TARGET:-",cont=tbl)

tbl[11,2]= gedit("", cont=tbl,coerce.with=as.numeric)

tbl[17,1]= gbutton("RUNBACKTEST  ",cont=tbl,handler=RBS)

tbl[22,1]<- plut<<-gbutton("PLOT GRAPH ",cont=tbl,handler=ploit)

tbl[22,2]<-rprt<<-gbutton("TRADEREPORT",cont=tbl,handler=report)


tbl[1,1]=img <- gimage("E:/clusterring/pr.1.png")

tbl[19,1]<-b<<-gbutton("GENERATING BACKTEST SUMMARY ",cont=tbl,handler=gbs)

tbl[24,1]<-gbutton("CLEAR",cont=tbl,handler=clear)


tbl[13,1] =glabel("STOP LOSS TARGET:-")

tbl[13,2] =gedit("", container=tbl,coerce.with=as.numeric)


visible(win)=TRUE

}




I  Didn't   put the   whole  function  handlers   and   the remaining
codes    for its  lengthiness   ,  my  issue   is  the   function  is
showing    some  problem   like   when  i  execute   the   function   and
called the  GUI   using   "trade()"   it is  showing   the GUI   ,but
when  I  click  any  button   it  is  showing  some  error    like   below
:-


Error in svalue(tbl[5, 2]) :

 error in evaluating the argument 'obj' in selecting a method for function
'svalue': Error in (function (classes, fdef, mtable)  :

 unable to find an inherited method for function ‘.tag’ for signature
‘"<invalid>", "guiWidgetsToolkitRGtk2"’


Can  any body   help  me  with this   issue   ,   I  am  sorry  if   I
had   not  follwed   any  rules  in here  ,  will  learn  if taught   .



Thank  You

ASHIS  DEB

        [[alternative HTML version deleted]]


______________________________________________
[hidden email] 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.