Area of a circle
## Warning: package 'plotrix' was built under R version 3.4.3
In my math class, we are studying how to calculate the area, circumference and diameter of a circle.
circlearea_r <- function(pi, radius) {
area_circle <- pi*radius^2
}
test_circle <- circlearea_r(22/7, 5)
test_circle
## [1] 78.57143
circlearea_d <- function(pi, diameter) {
area_circle <- (pi*diameter^2)/4
}
test_circled <- circlearea_d(22/7, 12)
test_circled
## [1] 113.1429
circle_area_c <- function(pi, circum) {
area_circle <- (circum^2)/(4*pi)
}
test_circlec <- circle_area_c(22/7, 16)
test_circlec
## [1] 20.36364
Drawing circles with ggplot
ggplot() + geom_circle(aes(x0 = 0, y0 = 0, r = 5, fill = 5))
symbols (0, 0, circles=1,fg="red")
# plot(BOD)
# require(plotrix)
# draw.circle(4,14,2,border="blue",col="tan2")