Bioequivalence and Bioavailability Forum

Main page Policy/Terms of Use Abbreviations Latest Posts

 Log-in |  Register |  Search

Back to the forum  Query: 2018-02-21 12:04 CET (UTC+1h)
 

A little off topic: data.frame members [R for BE/BA]

posted by ElMaestro - Denmark, 2018-01-22 23:49  - Posting: # 18254
Views: 872

Hi all,
:ok:
there is something about R internals that I don 't understand and I can best exemplify it using some code from power.TOST but my question really isn't about anything in that package.

Imagine I do this in R with powerTOST:

sampleN.RSABE(CV=0.3, theta0=0.95)
Nice.
Now, assume I don't want all that intermediate mumbojumbo, and let us for the time being completely forget the print/verbose/details option so I just want the sample size itself as a numeric.

If I inspect the code I see the last few lines:

    res <- data.frame(design = design, alpha = alpha, CVwT = CVwT,
        CVwR = CVwR, theta0 = theta0, theta1 = theta1, theta2 = theta2,
        n = n, power = pwr, targetpower = targetpower, nlast = nlast)
    names(res) <- c("Design", "alpha", "CVwT", "CVwR", "theta0",
        "theta1", "theta2", "Sample size", "Achieved power",
        "Target power", "nlast")
    if (print | details)
        return(invisible(res))
    else return(res)


...and therefore I can simply do this:
sampleN.RSABE(CV=0.3, theta0=0.95)$n
(the n column is baptised as "Sample size" but is still accessible via $n)

If I look at the corresponding code snippet from sampleN.TOST we have:
     res <- data.frame(design = design, alpha = alpha, CV = CV,
        theta0 = theta0, theta1 = theta1, theta2 = theta2, n = n,
        power = pow, targetpower = targetpower)
    names(res) <- c("Design", "alpha", "CV", "theta0", "theta1",
        "theta2", "Sample size", "Achieved power", "Target power")
    if (print)
        return(invisible(res))
    else return(res)


But if I go
sampleN.TOST(CV=0.3, theta0=0.95)$n
then I get NULL.

What determines that difference in behaviour? Why does the res data.frame from both the two functions not hold an extractable $n ?

Note, this really is solely about R behaviour and R function return/internals (if I want the sample sizes I can also easily get them via [1,7] or [1,8] from the sample size object returned; all this isn't really what this question is about).:-)

I could be wrong, but…


Best regards,
ElMaestro

- Bootstrapping for dissolution data is a relatively new hobby of mine.

Complete thread:

Back to the forum Activity
 Mix view
Bioequivalence and Bioavailability Forum | Admin contact
17,924 Posts in 3,815 Threads, 1,118 registered users;
30 users online (0 registered, 30 guests).

For every expert there is an equal and opposite expert.    Arthur C. Clarke

The BIOEQUIVALENCE / BIOAVAILABILITY FORUM is hosted by
BEBAC Ing. Helmut Schütz
XHTML/CSS RSS Feed