Increasing vector & another example [Two-Stage / GS Designs]

posted by Helmut Homepage – Vienna, Austria, 2015-02-21 14:13 (3724 d 05:09 ago) – Posting: # 14485
Views: 12,310

Hi ElMaestro,

❝ In C you can get punished real bad if you do stuff like that.


Makes sense.

❝ Looks like R knows that users make occasional mistakes and will reallocate the array length when the user tries to set something that is out of bounds.


Couldn’t find anything about in the man-pages or on R-help. IMHO, R should at least throw a warning.

Another surprising goodie:

x   <- runif(1e3)
ops <- 1e6
ptm <- proc.time()
for(i in 1:ops) { }
t0  <- proc.time()-ptm
ptm <- proc.time()
for(i in 1:ops) { y1 <- mean(x) }
t1  <- 1e6*(proc.time()-ptm-t0)/ops
ptm <- proc.time()
for(i in 1:ops) { y2 <- sum(x)/length(x) }
t2  <- 1e6*(proc.time()-ptm-t0)/ops
cat("\n",
  sprintf("%14s: %.2f %s", "mean()", t1[3], "\u03bcs/op\n"),
  sprintf("%14s: %.2f %s", "sum()/length()", t2[3], "\u03bcs/op\n\n"))


Dif-tor heh smusma 🖖🏼 Довге життя Україна! [image]
Helmut Schütz
[image]

The quality of responses received is directly proportional to the quality of the question asked. 🚮
Science Quotes

Complete thread:

UA Flag
Activity
 Admin contact
23,424 posts in 4,927 threads, 1,670 registered users;
145 visitors (0 registered, 145 guests [including 5 identified bots]).
Forum time: 20:22 CEST (Europe/Vienna)

If you tell the truth you don’t have to remember anything.    Mark Twain

The Bioequivalence and Bioavailability Forum is hosted by
BEBAC Ing. Helmut Schütz
HTML5