intro_r/script/integerq_modulo.R

55 lines
1.1 KiB
R
Executable File

#' ---
#' title: "Modulo and integer quotients"
#' date: "2021-11-24"
#' author: "Jose https://ajuda.multifarm.top"
#' output:
#' html_document:
#' code_folding: show
#' toc: yes
#' toc_float:
#' smooth_scroll: true
#' df_print: paged
#' highlight: zenburn
#' ---
#' remove objects
#'
objects()
rm(list = ls())
#' Integer quotients are obtained with '%/%'
#' Remainders are obtained with '%%'
#'
#' ## Finding the integer part of divisions
#'
120 %/% 14 #' There are 8 fourteens in 120
120 %% 14 #' and "8" is the remainder: 8*14 = 112; 112 + 8 = 120
120 %/% 3
120 %% 20 #' In this case the remainder is zero
#' Modulo may help to find odds and even numbers
120 %% 2 #' odds have modulo == 0
121 %% 2 #' even numbers have modulo == 1
#' Modulo will return "0" if the value to the left is a multiple of the value included in the right side of the symbol "%%"
#'
3450 %% 3 == 0
#' ## References
#'
#' R book second edition p 18
#'
## @book{crawley2012r,
## title={The R book},
## author={Crawley, Michael J},
## year={2012},
## publisher={John Wiley \& Sons}
## }