Numeric

The numeric data type can also hold non-integer rational values.

Input:

source_code/appendix_b_r/example03_numeric.r
pi = 3.14159
circle_radius = 10.2
circle_perimeter = 2 * pi * circle_radius
circle_area = pi * circle_radius * circle_radius
cat("Let there be a circle with the radius", circle_radius, "cm.
")
cat("Then the perimeter of the circle is", circle_perimeter, "cm.
")
cat("The area of the circle is", circle_area, "cm squared.
")

Output:

$ Rscript example03_numeric.r 
Let there be a circle with the radius 10.2 cm.
Then the perimeter of the circle is 64.08844 cm.
The area of the circle is 326.851 cm squared.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset