Nama : Renata Amalia Putri
NIM : 220605110074
Kelas : C (Reguler)
Mata Kuliah : Kalkulus
Dosen Pengampu : Prof. Dr. Suhartono, M.kom
Jurusan : Teknik Informatika
Universitas : UIN Maulana Malik Ibrahim
The inputs taken by functions and the outputs produced by them are not necessarily numbers. Often, they are quantities. Consider these examples of quantities: money, speed, blood pressure, height, volume. Consider money. We can count, add, and subtract money – just like we count, add, and subtract with numbers. But money has an additional property: the kind of currency. Money as an idea is an abstraction of the kind sometimes called a dimension. When we are dealing with a quantity that has dimension, it’s not enough to give a number to say “how much” of that dimension we have. We need also to give units.
x <- 7
R, like most computer languages, has a programming construct to represent operations that take one or more inputs and produce an output. In R, these are called “functions.” In R, everything you do involves a function, either explicitly or implicitly.
as_daily_income <- function(yearly_income, duration = 365) {
yearly_income / duration
}
as_daily_income(61362)
## [1] 168.1151
as_daily_income(61362, duration = 366)
## [1] 167.6557
There will be three quantities involved in even a simple calculation of this: the dosage, the amount of time since the dose was taken, and what’s called the “time constant”
dose <- 100 # mg
duration <- 10 # days
time_constant <- 4 # days
dose * exp(- duration / time_constant)
## [1] 8.2085
library(mosaic)
## Registered S3 method overwritten by 'mosaic':
## method from
## fortify.SpatialPolygonsDataFrame ggplot2
##
## The 'mosaic' package masks several functions from core packages in order to add
## additional features. The original behavior of these functions should not be affected by this.
##
## Attaching package: 'mosaic'
## The following objects are masked from 'package:dplyr':
##
## count, do, tally
## The following object is masked from 'package:Matrix':
##
## mean
## The following object is masked from 'package:ggplot2':
##
## stat
## The following objects are masked from 'package:stats':
##
## binom.test, cor, cor.test, cov, fivenum, IQR, median, prop.test,
## quantile, sd, t.test, var
## The following objects are masked from 'package:base':
##
## max, mean, min, prod, range, sample, sum
drug_remaining <- function(dose, duration, time_constant) {
dose * exp(- duration / time_constant)
}
t = 0:20
plotFun(drug_remaining(dose = 100, time_constant = 4, duration = t) ~ t, t.lim = range(0:20))
Daftar Pustaka
Kaplan, Daniel, 2020, Computer-age Calculus with R (https://dtkaplan.github.io/RforCalculus/)