I would like to be able to use two functions; qansari and pansari which are found in the function ansari.test. How can I evaluate these functions independently? Thanks. --Dale For example, when I load the function ... qansari <- function(p, m, n) { .C(R_qansari, as.integer(length(p)), q = as.double(p), as.integer(m), as.integer(n))$q } and attempt to evaluate ...> qansari( 0.025, 5, 5)Error in qansari(0.025, 5, 5) : object 'R_qansari' not found methods(ansari.test) stats:::ansari.test.default the two functions that are part of ansari.test.default: qansari <- function(p, m, n) { .C(R_qansari, as.integer(length(p)), q = as.double(p), as.integer(m), as.integer(n))$q } pansari <- function(q, m, n) { .C(R_pansari, as.integer(length(q)), p = as.double(q), as.integer(m), as.integer(n))$p }
Dale Steele wrote:> > I would like to be able to use two functions; qansari and pansari > which are found in the > function ansari.test. How can I evaluate these functions > independently? Thanks. --Dale > > For example, when I load the function ... > > qansari <- function(p, m, n) { > .C(R_qansari, as.integer(length(p)), q = as.double(p), > as.integer(m), as.integer(n))$q > } > > and attempt to evaluate ... > >> qansari( 0.025, 5, 5) > Error in qansari(0.025, 5, 5) : object 'R_qansari' not found >If R_qansari is the name of a compiled C subroutine you are trying to execute, then it needs to be passed to .C as a quoted string: .C( "R_qansari" , as.integer(length(p)), q = as.double(p), as.integer(m), as.integer(n))$q Otherwise R, as usual, is looking for a *variable* named R_qansari that it assumes holds a string that will tell it which C routine to call. It does not find such a variable and gives the error message shown above. -Charlie Dale Steele wrote:> > methods(ansari.test) > stats:::ansari.test.default > > the two functions that are part of ansari.test.default: > > qansari <- function(p, m, n) { > .C(R_qansari, as.integer(length(p)), q = as.double(p), > as.integer(m), as.integer(n))$q > } > > pansari <- function(q, m, n) { > .C(R_pansari, as.integer(length(q)), p = as.double(q), > as.integer(m), as.integer(n))$p > } > >-- View this message in context: http://n4.nabble.com/How-to-use-a-hidden-function-directly-tp1568392p1568401.html Sent from the R help mailing list archive at Nabble.com.
Dale Steele wrote:> > methods(ansari.test) > stats:::ansari.test.default > > the two functions that are part of ansari.test.default: > > qansari <- function(p, m, n) { > .C(R_qansari, as.integer(length(p)), q = as.double(p), > as.integer(m), as.integer(n))$q > } > > pansari <- function(q, m, n) { > .C(R_pansari, as.integer(length(q)), p = as.double(q), > as.integer(m), as.integer(n))$p > } >Sorry, I didn't consider this part of your message carefully. R_quansari and R_pansari are indeed variables, but they are unexported variables in the stats namespace. Therefore if you want to use these functions outside of their namespace, you will need something like: pansari <- function(q, m, n) { .C( stats:::R_pansari, as.integer(length(q)), p = as.double(q), as.integer(m), as.integer(n))$p } Hope this helps! -Charlie -- View this message in context: http://n4.nabble.com/How-to-use-a-hidden-function-directly-tp1568392p1568408.html Sent from the R help mailing list archive at Nabble.com.