Random allocation list generator


I have made a random allocation list generator using R Shiny. It is located at https://icostatistics.shinyapps.io/randlist/). The source code is on github.

Every now and then I get the request to make a random allocation list according to some specifications, usually for a randomised controlled trial (RCT). There are many R and Stata packages out there which does this, but I do this seldom enough to forget the specifications to the function calls. So I need to look it up every time. But then I discovered Shiny and wanted to learn it, and at the same time do something useful.

I had some specifications in my head:

  • Self-explanatory (to myself)

  • Export of not only the list but also the documentation of the generation for reproducibility


When setting up the random allocation list there are some technical terms I will try to explain. A lot of the terms are covered much better in ICH E9 Statistical Principles for Clinical Trials, and I recommend all to read this


According to ICH E9,

Randomisation introduces a deliberate element of chance into the assignment of treatments to subjects in a clinical trial.

Randomisation to either an intervention or a control treatment is the core concept of RCTs because it effectively breaks all confounding effects in your trial.

Randomisation is essentially tossing a coin to decide which treatment each trial subject is allocated to.

Random allocation list

Also known as the randomisation list or random sequence list. The random allocation list is essentially doing the coin toss for each subject prior to trial commencement. It is of utmost importance to keep the list hidden for all trial personnel and participants until the patient has been randomised.

In it’s simplest form it is a sequential list of treatments by randomisation number.

Randomisation number Allocation
1 Placebo
2 Active
3 Placebo
4 Placebo
5 Placebo
6 Placebo

Random allocation

What is generally known as “randomisation” is the event when the virtual coin toss is performed and the treatment is allocated to the randomised subject. Usually this is selecting the next available allocation from the random allocation list. From ICH E9:

The next subject to be randomised into a trial should always receive the treatment corresponding to the next free number in the appropriate randomisation schedule (in the respective stratum, if randomisation is stratified).

In open trials the allocated treatment is revealed to the trial subject and personnel. This can be done by picking the next available envelope, or by randomisation by a trial specific web page or electronic Case Report Form (eCRF).

In blinded trials only the randomisation number, corresponding to some treatment kit or box, is revealed. This can be done by picking the next available kit, or by being given kit number(s) through a web page.

The best way to do the actual allocation varies from trial to trial, and I think I need to write a separate post only on this issue.


According to ICH E9: > …, stratification by important prognostic factors measured at baseline (e.g. severity of disease, age, sex, etc..) may sometimes be valuable in order to promote balanced allocation within strata; this has greater potential benefit in small trials. The use of more than two or three stratification factors is rarely necessary, is less successful at achieving balance and is logistically troublesome.

In multicentre trials the random allocation list should be stratified by centre.

Stratification is achieved by producing one list per strata combination. E.g. if the randomisation of a multicenter trial is stratified by sex, the first list is for males in centre 1, then next for females in centre 1 and so on.

Block randomisation

When tossing a coin there is always a chance that the first 10 tosses will be heads, or 20 for that matter. In a study with 40 patients the probability of randomising at least 25 to 15 is 15%. Blocking the randomisation is a technique to avoid very skewed allocation.

Blocking the randomisation means that within each strata there are several blocks, and within each block the treatment allocation is balanced. E.g. if the block size is 4 then for each 4 randomised subjects there are two to each treatment.

According to ICH E9:

Although unrestricted randomisation is an acceptable approach, some advantages can generally be gained by randomising subjects in blocks. This helps to increase the comparability of the treatment groups, particularly when subject characteristics may change over time, as a result, for example, of changes in recruitment policy. It also provides a better guarantee that the treatment groups will be of nearly equal size.

I recommend to always use random blocks, e.g. with block sizes of 4, 6 and 8. If the investigator or staff doing the randomisation is blind to the block size, it is impossible to deduct the next treatment allocation. This is less important in blinded trials, but I usually do it anyways.


Random allocation lists are usually prepared using a computer. But a computer is inherently deterministic by nature, and cannot produce lists that are truly random. But they can produce something that looks random, and has the usual properties of randomness. The programs underlying these lists are called pseudo-random number generators.

One of the best things about computers is reproducibility. This is also the case with pseudo-random number genearators. If the state of the generator is the same, the same list will be produced. And the state is defined by a number referred to as the seed. My standard seed is 42, but when I want to get a truly random seed I go to the random.org web-page. This page uses atmospheric noise to produce truly random numbers. In my Shiny random allocation list generator I use the time in milliseconds when the seed is generated for a random seed.

Inge Christoffer Olsen

My research interests include statistical methods for clinical trials