signif( )

Round to a given number of significant figures. signif() is a base R function.

Required Library

# signif() is part of base R — no package installation needed

Syntax

signif(x, digits)

signif(x, digits) rounds a number (or vector of numbers) to digits significant figures. Significant figures count from the first non-zero digit, regardless of the position of the decimal point. Use signif() when the relative precision of a measurement matters — which is the case for most analytical chemistry results.

signif(x, digits = 6)

signif(x, digits = 6) shows the default value of digits. If you omit digits, R keeps 6 significant figures. In practice you should always state digits explicitly to match the precision of your method.

NoteCoding convention — only round at the point of printing

Store intermediate calculated values at full precision. Call signif() only inside cat() when displaying a final result. Rounding intermediate values introduces accumulating errors in multi-step pharmaceutical calculations.

# ✓ Correct — full precision stored, rounded only when printed
C2_ug_ml <- (absorbance - std_intercept) / std_slope
cat("Concentration:", signif(C2_ug_ml, 3), "µg/mL\n")

# ✗ Avoid — rounding before using in further calculations
C2_ug_ml <- signif((absorbance - std_intercept) / std_slope, 3)
TipRule of thumb

Use signif() for most analytical and pharmacokinetic results where the number of significant figures is specified by the instrument or method (e.g., 3 sig figs from a UV spectrophotometer). Use round() when a fixed number of decimal places is required — such as percentages always displayed to 2 decimal places.

Argument Overview

Required arguments must be included when using a function while optional arguments can be included on demand.

x — number(s) to round numeric | integer Required

A single number or a numeric vector. signif() is vectorised — it applies element-wise to every value in the vector.

Data Types: numeric | integer

digits — number of significant figures integer Required

The number of significant figures to keep. Must be a positive integer. A significant figure is any digit from the first non-zero digit onward.

x digits Result Explanation
31.187 3 31.2 Digits: 3, 1, 2
0.004512 2 0.0045 Digits: 4, 5
158400 3 158000 Digits: 1, 5, 8

Data Types: integer · Must be ≥ 1

Examples

Reporting an analytical concentration
Comparing signif() to the raw value
Works the same for very small and very large numbers
Applying to a whole column

When used inside cat() with a vector, signif() applies to every element. For adding a rounded column to a tibble, use mutate() — but only if the rounded value itself is the final deliverable (e.g., a formatted report column), not if it will be used in further calculations.

signif() vs round() — which to use?