library(mosaicCalc)
## Warning: package 'mosaicCalc' was built under R version 4.2.2
## Loading required package: mosaic
## Warning: package 'mosaic' was built under R version 4.2.2
## 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
## Warning: package 'mosaicCore' was built under R version 4.2.2
## 
## Attaching package: 'mosaicCore'
## The following objects are masked from 'package:dplyr':
## 
##     count, tally
## 
## Attaching package: 'mosaicCalc'
## The following object is masked from 'package:stats':
## 
##     D

Bab 2 Latihan

2.1.1.1 Latihan 1

x <- 10
slice_plot(A * x ^  2 ~ A, domain(A = range(-2,  3)))

Jelaskan mengapa grafik tersebut tidak terlihat seperti parabola, meskipun merupakan grafik dari Ax2

JAWABAN: Perhatikan bahwa masukan ke fungsi adalah A, bukan x. Nilai dari xtelah diatur ke 10 — grafik dibuat pada rentang Adari− 2−2 ke 3.

2.1.1.2 Latihan 2

Terjemahkan setiap ekspresi ini dalam notasi matematika tradisional ke dalam plot.

A. 4x−7di jendela x dari 0 sampai 10 Jawab :

slice_plot( 4 * x - 7 ~ x, domain(x = range(0, 10) ))

B. Cos ⁡5x di jendela x dari− 1−1 ke 1
Jawab :

slice_plot( cos(5 * x) ~ x, domain(x = range(-1, 1)))

C. Cos⁡2t di jendelatdari 0 sampai 5.

Jawab:

slice_plot( cos(2 * t) ~ t, domain(t = range(0,5) ))

2.1.1.3 Latihan 3

Buatlah codingan yang anda gunakan untuk membuat plot yang sama :

a.


Jawab:

slice_plot(2*x - 3 ~ x, domain(x = range(0, 5)))

b.

Jawab :

slice_plot(t^2 ~ t, domain(t = range(-2, 2)))

2.2.1.1 Latihan 1

Buat codingan R untuk menduplikasikan setiap plot ini.

  1. File data "utilities.csv"memiliki catatan utilitas untuk sebuah rumah di St. Paul, Minnesota, AS. Buat plot ini, termasuk labelnya:

Jawab :

Utilities <- read.csv(
  "http://www.mosaic-web.org/go/datasets/utilities.csv")

gf_point( 
  temp ~ month, data=Utilities) %>% 
  gf_labs(x = "Month (Jan=1, Dec=12)",
          y = "Temperature (F)",
          main = "Ave. Monthly Temp.")

  1. Dari "utilities.csv"file data, buatlah plot tagihan bulanan rumah tangga untuk gas alam versus suhu rata-rata. Garis tersebut memiliki kemiringan−5−5USD/gelar dan mencegat 300 USD

Jawab :

gf_point(
  gasbill ~ temp, data=Utilities) %>%
  gf_labs(xlab = "Temperature (F)",
          ylab = "Expenditures ($US)",
          main = "Natural Gas Use") %>%
  slice_plot( 300 - 5*temp ~ temp, color="blue")