Dosen Pengampu : Prof.Dr.Suhartono,M.Kom
Lembaga : UIN Maliki Malang
Jurusan : Teknik Informatika
Fakultas : Sains Dan Teknologi
Selain fungsi operator aritmetik, pada R juga telah tersedia fungsi aritmetik yang lain seperti logaritmik, ekponensial, trigonometri, dll.
log2(8) # logaritma basis 2 untuk 8
## [1] 3
log10(8) # logaritma basis 10 untuk 8
## [1] 0.90309
exp(8) # eksponensial 8
## [1] 2980.958
2.Fungsi trigonometri
fungsi trigonometri yang ditampilkan seperti sin,cos, tan, dll.
x <- 50
cos(x) # cos x
## [1] 0.964966
sin(x) # Sin x
## [1] -0.2623749
tan(x) # Tan x
## [1] -0.2719006
acos(x) # arc-cos x
## Warning in acos(x): NaNs produced
## [1] NaN
asin(x) # arc-sin x
## Warning in asin(x): NaNs produced
## [1] NaN
atan(x) #arc-tan x
## [1] 1.550799
x dalam fungsi trigonometri memiliki satuan radian
Berikut adalah salah satu contoh penggunaannya:
cos(pi)
## [1] -1
Pada Paket pracma fungsi-fungsi trigonometri dapat ditambah lagi. Fungsi-fungsi tersebut antara lain:
cot(x) # cotan x csc(x) # cosecan x sec(x) # secan x acot(x) # arc-cotan x acsc(x) # arc-cosecan x asec(x) # arc-secan x
fungsi hiperbolik yang tersedia antara lain:
coth(x) csch(x) sech(x) acoth(x) acsch(x) asech(x)
Fungsi tersebut dapat ditambah lagi dari Paket pracma. Fungsi-fungsi yang tersedia antara lain:
coth(x) csch(x) sech(x) acoth(x) acsch(x) asech(x)
Fungsi lainnya yang dapat digunakan adalah fungsi absolut, akar kuadrat, dll. Berikut adalah contoh sintaks penggunaan fungsi absolut dan akar kuadrat.
abs(-2) # nilai absolut -2
## [1] 2
sqrt(4) # akar kuadrat 4
## [1] 2
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.