Extracting the complete decimal part of the number in R

Viewed 11828

How can I extract the decimal part of the number? Say I have a decimal number, my_num <- 3.55.

1 Answers

There are multiple ways to solve and extract the decimal part some are: lets store the result in dec

  1. dec <- my_num - floor(my_num)
  2. dec <- my_num%%1
  3. dec <- my_num - as.integer(my_num)
  4. dec <- my_num - trunc(my_num)

all these will result the same.

Related