Skip to content

To define a function which includes two functions as arguments such as "plot" and "text"

5 messages · Yashwanth M.R, Uwe Ligges

#
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.
#
On 24.02.2012 12:22, Yashwanth M.R wrote:
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
3 days later
1 day later
#
On 28.02.2012 07:04, Yashwanth M.R wrote:
Yashwanth M.R,

this is the R-help mailing list, not my personal mail account (and "Mr." 
is inappropriate in any case).
That is the value returned from the previous function call, not a 
command nor a function.
Yes, since that ws the result of calling the previous function.

Your output is not reproducible hence it is hard to help for us, we do 
not really understand what you are going to do with functions, and you 
should start reading "An Introduction to R" in order to get a basic 
sense of R. Finally, this is a mailning list driven by volunteers, and 
sense some rudeness in demanding things "ASAP".

Best,
Uwe Ligges