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

posted by Helmut Homepage – Vienna, Austria, 2015-02-21 14:13 (4135 d 20:40 ago) – Posting: # 14485
Views: 14,566

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,654 posts in 4,992 threads, 1,570 registered users;
183 visitors (0 registered, 183 guests [including 19 identified bots]).
Forum time: 11:53 CEST (Europe/Vienna)

Actually, science starts to become interesting
only where it ends.    Justus von Liebig

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