A little off topic: data.frame members [R for BE/BA]
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:
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)
...and therefore I can simply do this:
(the n column is baptised as "Sample size" but is still accessible via $n)
If I look at the corresponding code snippet from
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")
But if I go
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).
if (3) 4
typeof(b[,1]) ##aha, integer?
b[,1]+1 ##then let me add 1
"(...) targeted cancer therapies will benefit fewer than 2 percent of the cancer patients they’re aimed at. That reality is often lost on consumers, who are being fed a steady diet of winning anecdotes about miracle cures." New York Times (ed.), June 9, 2018.