Anisa Dhana shows us a quick example of how to calculate Z score with R:

In short, the z-score is a measure that shows how much away (below or above) of the mean is a specific value (individual) in a given dataset. In the example below, I am going to measure the z value of body mass index (BMI) in a dataset from NHANES.

Because R is a set-oriented, functional programming language, the answer is quite simple.