R Markdown

Contoh 2.1.1

contoh.2.1.1 <- function(expr, age, t) {
  sxt <- eval ({x=age+t; expr})
  sx <- eval ({x=age; expr})
  output <- (sx-sxt)/sx
  output }
expr <- expression(1-(x/100))
contoh.2.1.1(expr, age=30, t=10)
## [1] 0.1428571

Contoh 2.1.2

contoh.2.1.2 <- function(expr, age, t) {
  sxt <- eval ({x=age+t; expr})
  sx <- eval ({x=age; expr})
  output <- (sx-sxt)/sx
  output }

expr <- expression((1-(x/100))^0.5)
contoh.2.1.2(expr, age=36, t=15) #15q36
## [1] 0.125
1-contoh.2.1.2(expr, age=19, t=17)
## [1] 0.8888889
#17p19

Contoh 2.1.3

contoh.2.1.3 <- function(expr, age, t) {
  sxt <- eval ({x=age+t; expr})
  sx <- eval ({x=age; expr})
  output <- (sx-sxt)/sx
  output }

expr <- expression(exp(-x/12))
tpx <- 1-contoh.2.1.3(expr, age=13, t=7) 
tpx
## [1] 0.5580351