Learn R Programming

cwhmisc (version 3.0)

frac: Fractional part of number

Description

Split off fractional part of a number

Usage

frac(x,d)

Arguments

x
Numerical vector.
d
If not missing, determines number of decimals after "."

Value

  • fractional part, if d is missing; else $round(10^d*fractional part)$, i.e. the digits without the leading "0.".

Examples

Run this code
frac(c(0,pi,2*pi,30*pi))    # 0.000000 0.141593 0.283185 0.247780
frac(c(0,pi,2*pi,30*pi),3)  # 0 142 283 248

Run the code above in your browser using DataLab