trunc(x) is a truncate function in R, which rounds to the nearest integer in the direction of 0.
Example of trunc() function in R:
# truncate function in R trunc(125.2395)
output:
[1] 125
# truncate function in R for negative decimal value trunc(-125.2395)
As truncate function in R, rounds the nearest integer in direction of 0, the output will be -125
output:
[1] -125
Example of trunc() function in R for a vector:
# truncate function in R for a vector trunc(c(1.234,2.342,-4.562,5.671,12.345,-14.567))
output:
[1] 1 2 -4 5 12 -14