Yashwanth M.R
2012-Feb-24 11:22 UTC
[R] To define a function which includes two functions as arguments such as "plot" and "text"
Here is the two functions which I have used during my practice. *plot(Telco.rpart.METHOD.CLASS,compress=FALSE,uniform=TRUE) text(Telco.rpart.METHOD.CLASS,use.n = TRUE, cex = .75))* "Telco.rpart.METHOD.CLASS" is my "rpart" object of the method "class". If I run this, *Telco.Rpart.PLOT.TEXT <- c(plot(Telco.rpart.METHOD.CLASS,compress=FALSE,uniform=TRUE), text(Telco.rpart.METHOD.CLASS,use.n = TRUE, cex .75)) * http://r.789695.n4.nabble.com/file/n4416881/Rpart.gif the output is getting generated as shown in the figure. But if I solely run the same command "Telco.Rpart.PLOT.TEXT" right after the above, the output is as below, /$x [1] 4.035156 1.000000 7.070312 3.015625 2.000000 4.031250 [7] 3.000000 5.062500 4.000000 6.125000 5.000000 7.250000 [13] 6.500000 6.000000 7.000000 8.000000 11.125000 10.250000 [19] 9.500000 9.000000 10.000000 11.000000 12.000000 $y [1] 1.125 1.000 1.000 0.875 0.750 0.750 0.625 0.625 0.500 0.500 0.375 [12] 0.375 0.250 0.125 0.125 0.250 0.875 0.750 0.625 0.500 0.500 0.625 [23] 0.750 / Please help me in getting the output which is there is the Image.. Regards, Yashwanth M,R -- View this message in context: http://r.789695.n4.nabble.com/To-define-a-function-which-includes-two-functions-as-arguments-such-as-plot-and-text-tp4416881p4416881.html Sent from the R help mailing list archive at Nabble.com.
Uwe Ligges
2012-Feb-24 15:44 UTC
[R] To define a function which includes two functions as arguments such as "plot" and "text"
On 24.02.2012 12:22, Yashwanth M.R wrote:> Here is the two functions which I have used during my practice. > > *plot(Telco.rpart.METHOD.CLASS,compress=FALSE,uniform=TRUE) > > text(Telco.rpart.METHOD.CLASS,use.n = TRUE, cex = .75))* > > "Telco.rpart.METHOD.CLASS" is my "rpart" object of the method "class". > > If I run this, > > *Telco.Rpart.PLOT.TEXT<- > c(plot(Telco.rpart.METHOD.CLASS,compress=FALSE,uniform=TRUE), > text(Telco.rpart.METHOD.CLASS,use.n = TRUE, cex > .75))c() concatenates the returned values of the two functions. If you want to define a sequence of function calls, define them within your own function, calling that new function will produce your desired results, as far as I understand. Uwe Ligges> > http://r.789695.n4.nabble.com/file/n4416881/Rpart.gif > > the output is getting generated as shown in the figure. But if I solely run > the same command "Telco.Rpart.PLOT.TEXT" right after the above, the output > is as below, > > /$x > [1] 4.035156 1.000000 7.070312 3.015625 2.000000 4.031250 > [7] 3.000000 5.062500 4.000000 6.125000 5.000000 7.250000 > [13] 6.500000 6.000000 7.000000 8.000000 11.125000 10.250000 > [19] 9.500000 9.000000 10.000000 11.000000 12.000000 > > $y > [1] 1.125 1.000 1.000 0.875 0.750 0.750 0.625 0.625 0.500 0.500 0.375 > [12] 0.375 0.250 0.125 0.125 0.250 0.875 0.750 0.625 0.500 0.500 0.625 > [23] 0.750 > / > > > Please help me in getting the output which is there is the Image.. > > Regards, > Yashwanth M,R > > -- > View this message in context: http://r.789695.n4.nabble.com/To-define-a-function-which-includes-two-functions-as-arguments-such-as-plot-and-text-tp4416881p4416881.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org 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.