Optimasi merupakan salah satu operasi pada kalkulus dimana Optimasi: menemukan input yang menghasilkan output terbesar, Di dunia banyak sekali data yang memiliki batas maksimal dan batas minimum, Dalam kalkulus sendiri terdapat optimasi yang dapat membantu kita dalam meencari nilai terbsesar dari suatu ouput
library(mosaicCalc)
## Loading required package: 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
## Loading required package: mosaicCore
##
## Attaching package: 'mosaicCore'
## The following objects are masked from 'package:dplyr':
##
## count, tally
## The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
## which was just loaded, will retire in October 2023.
## Please refer to R-spatial evolution reports for details, especially
## https://r-spatial.org/r/2023/05/15/evolution4.html.
## It may be desirable to make the sf package available;
## package maintainers should consider adding sf to Suggests:.
## The sp package is now running under evolution status 2
## (status 2 uses the sf package in place of rgdal)
##
## Attaching package: 'mosaicCalc'
## The following object is masked from 'package:stats':
##
## D
Engines$bore
## [1] 13.5 15.0 16.5 21.0 24.0 24.0 24.0 27.0 15.9 27.0 34.0 44.0
## [13] 70.0 90.0 92.0 98.0 100.0 106.0 102.0 102.0 124.0 105.0 124.0 133.0
## [25] 101.0 102.0 194.0 155.0 140.0 165.0 239.0 162.0 250.0 356.0 406.0 508.0
## [37] 457.0 900.0 840.0
summary(Engines)
## Engine mass ncylinder strokes
## Length:39 Min. : 0.14 Min. : 1.000 Min. :2.00
## Class :character 1st Qu.: 1.69 1st Qu.: 1.500 1st Qu.:4.00
## Mode :character Median : 135.00 Median : 6.000 Median :4.00
## Mean : 6511.12 Mean : 7.795 Mean :3.59
## 3rd Qu.: 1290.00 3rd Qu.:12.000 3rd Qu.:4.00
## Max. :102300.00 Max. :24.000 Max. :4.00
## displacement bore stroke BHP
## Min. : 2 Min. : 13.5 Min. : 12.5 Min. : 0.450
## 1st Qu.: 35 1st Qu.: 30.5 1st Qu.: 26.5 1st Qu.: 3.475
## Median : 4700 Median :102.0 Median : 92.0 Median : 140.000
## Mean : 738830 Mean :166.8 Mean : 213.0 Mean : 2605.668
## 3rd Qu.: 58900 3rd Qu.:163.5 3rd Qu.: 170.0 3rd Qu.: 2275.000
## Max. :11900000 Max. :900.0 Max. :1800.0 Max. :27800.000
## RPM
## Min. : 110
## 1st Qu.: 2300
## Median : 2800
## Mean : 6235
## 3rd Qu.: 9000
## Max. :26000
x <- Engines$bore
Engines merupakan sekumpulan data yang sudah di sediakan oleh R dalam engines tersebut banyak sekali kumpulan data, namun pada kesempatan kali ini saya akan menggunakan tipe dari data bore.
summary salah satu perintah bawaan dari R untuk mencari beberapa nilai statistika mulai dari nilai max, nilai min, mean median quartil
x[1:20]
## [1] 13.5 15.0 16.5 21.0 24.0 24.0 24.0 27.0 15.9 27.0 34.0 44.0
## [13] 70.0 90.0 92.0 98.0 100.0 106.0 102.0 102.0
y <- x[1:20]
min(y)
## [1] 13.5
max(y)
## [1] 106
min dan max digunakan untuk mencari nilai terbesar dan terkecil dengan rentang data mulai dari 1 sampai 20
plot(x[1:20] ,type = "l", col = "blue", lwd = 2, ylim = c(min(y), 120))
abline(h = max(y), col = "red", lty = 1)
abline(h = min(y), col = "green", lty = 1)
x_label <- "Data Point"
y_label <- "Nilai Bore"
title(main = "Grafik Garis dengan Nilai Bore", xlab = x_label, ylab = y_label)
Untuk menampilkan data sebagai grafik ada beberapa cara untuk
melakukannya mulai dari slice plot dengan library mosaicCalc, namun kalo
ini saya akan menggunakan plot bawaan dan untuk memeberikan garis bisa
mengnakan abline
data_batang <- x[1:20]
barplot(data_batang, col = "blue", names.arg = 1:20, ylim = c(0, 120), ylab = "Nilai Bore", xlab = "Data Point")
abline(h = max(data_batang), col = "red", lty = 2)
abline(h = min(data_batang), col = "green", lty = 2)