Gráficos

Questão 1

Primeiro gráfico

par(mar = c(4.5, 4.5, 1, 1))
plot(clock, MRT_1F, type = "o", pch = 4, col = "black",
     ylim = c(0, 520),
     xlab = "Time between Things requests (seconds)",
     ylab = "Response Time (sec.)")
lines(clock, MRT_3F,    type = "o", pch = 16, col = "yellow")
lines(clock, MRT_5F,    type = "o", pch = 1,  col = "red")
lines(clock, MRT_10F,   type = "o", pch = 2,  col = "blue")
lines(clock, MRT_15F,   type = "o", pch = 5,  col = "purple")
lines(clock, MRT_sem_F, type = "o", pch = 4,  col = "green", lty = 2)
legend("topright",
       legend = c("1 Fog", "3 Fogs", "5 Fogs", "10 Fogs", "15 Fogs", "w/o Fog"),
       col    = c("black", "yellow", "red", "blue", "purple", "green"),
       pch    = c(4, 16, 1, 2, 5, 4),
       lty    = c(1, 1, 1, 1, 1, 2),
       cex    = 0.8)

Segundo gráfico

cores <- c("#E6E6E6", "#666666")
configs <- list(
  list(dados = MRT_1F,  legenda = "1 Fog"),
  list(dados = MRT_3F,  legenda = "3 Fogs"),
  list(dados = MRT_5F,  legenda = "5 Fogs"),
  list(dados = MRT_10F, legenda = "10 Fogs"),
  list(dados = MRT_15F, legenda = "15 Fogs")
)

par(mar = c(4.5, 4.5, 1, 1))
for (cfg in configs) {
  barplot(rbind(MRT_sem_F, cfg$dados), beside = TRUE, log = "y",
          col = cores, names.arg = clock,
          xlab = "Time between Things requests",
          ylab = "Response time (s)",
          legend.text = c("w/o Fog", cfg$legenda),
          args.legend = list(x = "topright", cex = 0.7))
}

layout(1)

Questão 2

Questão 3

temp_maio_F <- airquality$Temp[airquality$Month == 5]
temp_maio_C <- (temp_maio_F - 32) / 1.8

hist(temp_maio_C,
     freq = FALSE,
     col = "lightblue",
     border = "white",
     main = "Histograma das temperaturas de maio (airquality)",
     xlab = "Temperatura (°C)",
     ylab = "Densidade")

lines(density(temp_maio_C), col = "red", lwd = 2)

Questão 4

sales <- read.table("https://www.dropbox.com/scl/fi/mpjt4uuqb5vtmfiw38phk/Sales.txt?rlkey=93jlz79xwrrt7ah66d5k403d7&dl=1", header = TRUE)
pct <- round(sales$SALES / sum(sales$SALES) * 100, 1)
rotulos <- paste0(pct, "%")

cores <- c("#E41A1C", "#377EB8", "#4DAF4A", "#984EA3", "#FF7F00", "#FFD92F")

pie(sales$SALES,
    labels = rotulos,
    col = cores,
    main = "Porcentagem do total de vendas por país")

legend("topright",
       legend = sales$COUNTRY,
       fill = cores,
       title = "País",
       cex = 0.9)

Questão 5

boxplot(count ~ spray,
        data = InsectSprays,
        outline = FALSE,
        col = "yellow",
        main = "Contagem de insetos por tipo de inseticida",
        xlab = "Tipo de inseticida (spray)",
        ylab = "Contagem de insetos")