To change the decimal points in R, you can use the round()
function. The round()
function takes two arguments: the number you want to round, and the number of decimal places you want to round to. For example, to round the number 3.14159 to two decimal places, you would use the following code:
main.r18 chars2 lines
This would return the value 3.14
.
Alternatively, you can use the options()
function to set the global default number of decimal places for all numeric output in R. For example, to set the default number of decimal places to two, you would use the following code:
main.r18 chars2 lines
This will affect all subsequent numeric output in your R session.
gistlibby LogSnag