NIM: 2206065110100

School: Maulana Malik Ibrahim Islamic State University of Malang

Departement: Computer Science

Before we go the slice plot. Let’s take a situation where we wanna know the rest of the drug in the body 7 days after a dose of 80mg was admnistrated.

In this situation, there will be three quantities involved to eliminate the drug remaining amount.

-> The quantites:
  • dose
  • duration
  • time_constant
dose <- 80 # mg
duration <- 7 # days
time_constant <- 2 # days
dose * exp(- duration / time_constant)
## [1] 2.415791
-> Implemented by Using Function

The function is called drug_remaining.

drug_remaining <- function(dose, duration, time_constant) {
  dose * exp(- duration / time_constant)
}

# Initialize the parameter values
drug_remaining(dose = 80, duration = 7, time_constant = 2)
## [1] 2.415791
-> Draw the drug_remaining Function to a Graph Using The Package’s slice_plot() Operation

In this case, we want to know how the graph look based on duration interval from 0 to 40 days.

We’re gonna use mosaicCalc library operation and slice_plot

library(mosaicCalc)
## Loading required package: mosaicCore
## Loading required package: Deriv
## Loading required package: Ryacas
## 
## Attaching package: 'Ryacas'
## The following object is masked from 'package:stats':
## 
##     integrate
## The following objects are masked from 'package:base':
## 
##     %*%, diag, diag<-, lower.tri, upper.tri
## Registered S3 method overwritten by 'mosaic':
##   method                           from   
##   fortify.SpatialPolygonsDataFrame ggplot2
## 
## Attaching package: 'mosaicCalc'
## The following object is masked from 'package:stats':
## 
##     D

Here’s the program:

slice_plot(
  drug_remaining(dose = 80, time_constant = 5, duration = t) ~ t,
  domain(t = 0:40)
)