How to Convert Between Z-Scores and Percentiles in R


z-score tells us how many standard deviations away a certain value is from the mean of a dataset.

percentile tells us what percentage of observations fall below a certain value in a dataset.

Often you may want to convert between z-scores and percentiles.

You can use the following methods to do so in R:

Method 1: Convert Z-Scores to Percentiles

percentile <- pnorm(z)

Method 2: Convert Percentiles to Z-Scores

z <- qnorm(percentile)

The following examples show how to use each method in practice.

Example 1: Convert Z-Scores to Percentiles in R

We can use the built-in pnorm function in R to convert a z-score to a percentile.

For example, here is how to convert a z-score of 1.78 to a percentile:

#convert z-score of 1.78 to percentile
percentile <- pnorm(1.78)

#display percentile
percentile

[1] 0.962462

It turns out that a z-score of 1.78 corresponds to a percentile of 96.2.

We interpret this to mean that a z-score of 1.78 is larger than about 96.2% of all other values in the dataset.

Example 2: Convert Percentiles to Z-Scores in R

We can use the built-in qnorm function in R to convert a percentile to a z-score.

For example, here is how to convert a percentile of 0.85 to a z-score:

#convert percentile of 0.85 to z-score
z <- qnorm(0.85)

#display z-score
z

[1] 1.036433

It turns out that a percentile of 0.85 corresponds to a z-score of 1.036.

We interpret this to mean that a data value located at the 85th percentile in a dataset has a z-score of 1.036.

Also note that we can use the qnorm function to convert an entire vector of percentiles to z-scores:

#define vector of percentiles
p_vector <- c(0.1, 0.35, 0.5, 0.55, 0.7, 0.9, 0.92)

#convert all percentiles in vector to z-scores
qnorm(p_vector)

[1] -1.2815516 -0.3853205  0.0000000  0.1256613  0.5244005  1.2815516  1.4050716

Here’s how to interpret the output:

  • A percentile of 0.1 corresponds to a z-score of -1.28.
  • A percentile of 0.35 correspond to a z-score of -0.38.
  • A percentile of 0.5 corresponds to a z-score of 0.

And so on.

Additional Resources

The following tutorials explain how to perform other common tasks:

How to Calculate Percentiles in R
How to Calculate Percentile Rank in R
How to Interpret Z-Scores

Leave a Reply

Your email address will not be published.