Gráfico de linhas com os seis cenários (1, 3, 5, 10, 15 e sem Fog):
MRT_1F <- c(517.1468515630205, 85.13094142168089, 30.333207896694553,
12.694776264558937, 3.3041601673945418, 1.1823111717498882,
1.1892293502386786)
MRT_3F <- c(156.68929936163462, 11.540837783562276, 0.4512835621696538,
0.4509797929766453, 0.4502068233039181, 0.4496185276300172,
0.4543157082191288)
MRT_5F <- c(83.90319666471157, 0.3068151086494968, 0.30522314133037304,
0.3072588968084928, 0.30655265997285697, 0.3055812715727718,
0.3053297166713006)
MRT_10F <- c(29.55430642951759, 0.19832832665772515, 0.1971923924717474,
0.19796648905716516, 0.19615594370806338, 0.2034569237883263,
0.19617420889447737)
MRT_15F <- c(11.317736530583566, 0.167364215666193, 0.16172168266811013,
0.16701085329580515, 0.1598052657153692, 0.1645934043532696,
0.16216563797118075)
MRT_sem_F <- c(11.93430909937736, 0.6095414637034009,
0.6060645101029295, 0.612167181646899, 0.6146761002685637,
0.6096747087200697, 0.6125810476877268)
clock <- c(0.1, 0.5, 1, 1.5, 2, 2.5, 3)
cores <- c("black", "yellow", "red", "blue", "purple", "green")
pontos <- c(4, 0, 1, 2, 5, 4)
matplot(clock,
cbind(MRT_1F, MRT_3F, MRT_5F, MRT_10F, MRT_15F, MRT_sem_F),
type = "o", lty = 1, pch = pontos, col = cores,
xlab = "Time between Things requests (seconds)",
ylab = "Response Time (sec.)")
legend("topright",
legend = c("1 Fog", "3 Fogs", "5 Fogs", "10 Fogs", "15 Fogs", "w/o Fog"),
col = cores, pch = pontos, lty = 1, cex = 0.8)
Gráficos de barras (escala logarítmica em y), organizados com
layout():
cores_barras <- c("#E6E6E6", "#666666")
graphics::layout(matrix(c(1, 2,
3, 4,
5, 0), nrow = 3, byrow = TRUE))
cenarios <- list("1 Fog" = MRT_1F,
"3 Fogs" = MRT_3F,
"5 Fogs" = MRT_5F,
"10 Fogs" = MRT_10F,
"15 Fogs" = MRT_15F)
for (nome in names(cenarios)) {
dados <- rbind(MRT_sem_F, cenarios[[nome]])
barplot(dados, beside = TRUE, log = "y", col = cores_barras,
names.arg = clock,
xlab = "Time between Things requests",
ylab = "Response time (s)")
legend("topright", legend = c("w/o Fog", nome),
fill = cores_barras, cex = 0.8)
}
graphics::layout(1)
refeicao <- matrix(c(53.8, 33.9, 2.6, 0.0,
43.6, 54.2, 60.5, 21.4,
2.6, 11.9, 36.8, 78.6),
nrow = 3, byrow = TRUE,
dimnames = list(c("Good", "Very Good", "Excellent"),
c("$10-19", "$20-29", "$30-39", "$40-49")))
barplot(refeicao,
col = c("#9ecae1", "#4292c6", "#08519c"),
main = "Qualidade da refeição por faixa de preço",
xlab = "Preço da refeição (Meal Price)",
ylab = "Porcentagem (%)",
ylim = c(0, 120),
legend.text = rownames(refeicao),
args.legend = list(x = "top", horiz = TRUE, title = "Quality Rating"))
maio <- subset(airquality, Month == 5)
temp_c <- (maio$Temp - 32) / 1.8
hist(temp_c, freq = FALSE, col = "lightblue", border = "white",
main = "Temperaturas de maio (airquality)",
xlab = "Temperatura (°C)",
ylab = "Densidade")
lines(density(temp_c), col = "red", lwd = 2)
boxplot(count ~ spray, data = InsectSprays,
outline = FALSE, col = "yellow",
main = "Contagem de insetos por tipo de inseticida",
xlab = "Tipo de inseticida",
ylab = "Número de insetos")
para_mb <- function(x) {
valor <- as.numeric(sub("^([0-9.]+)([A-Za-z]+)$", "\\1", x))
unidade <- sub("^([0-9.]+)([A-Za-z]+)$", "\\2", x)
fator <- c(B = 1 / 1024^2, KB = 1 / 1024, MB = 1, GB = 1024, TB = 1000000)
valor * unname(fator[unidade])
}
prepara <- function(arquivo) {
d <- read.csv(achar(arquivo), check.names = FALSE, stringsAsFactors = FALSE)
padrao <- "^.*\\s([0-9]{2}):([0-9]{2}):([0-9.]+)$"
seg <- as.numeric(sub(padrao, "\\1", d$currentTime)) * 3600 +
as.numeric(sub(padrao, "\\2", d$currentTime)) * 60 +
as.numeric(sub(padrao, "\\3", d$currentTime))
dias <- cumsum(c(0, diff(seg) < 0))
tempo <- as.POSIXct(substr(d$currentTime[1], 1, 10), tz = "UTC") + seg + dias * 86400
data.frame(hora = as.numeric(difftime(tempo, tempo[1], units = "hours")),
mem = para_mb(d$usedMemory))
}
arquivos <- c("None Workload" = "monitoringCloudData_NONE.csv",
"Workload of 0.1" = "monitoringCloudData_0.1.csv",
"Workload of 0.5" = "monitoringCloudData_0.5.csv",
"Workload of 1.0" = "monitoringCloudData_1.csv")
graphics::layout(matrix(1:4, nrow = 2, byrow = TRUE))
for (nome in names(arquivos)) {
d <- prepara(arquivos[[nome]])
plot(d$hora, d$mem, type = "l",
main = paste0("Memory Analysis (", nome, ")"),
xlab = "Time (hour)", ylab = "Used Memory (MB)")
}
graphics::layout(1)
netflix <- read.csv(achar("netflix_titles.csv"), stringsAsFactors = FALSE,
na.strings = c("", "NA"))
um_pais <- netflix[!is.na(netflix$country) & !grepl(",", netflix$country), ]
um_pais$country <- trimws(um_pais$country)
top10 <- head(sort(table(um_pais$country), decreasing = TRUE), 10)
top10_df <- data.frame(Pais = names(top10), Total = as.integer(top10))
plot_ly(top10_df, labels = ~Pais, values = ~Total, type = "pie",
textinfo = "label+percent") %>%
layout(title = "Top 10 países com mais conteúdo na Netflix (um único país de origem)")
plot_ly(type = "table",
header = list(values = c("País", "Total de conteúdos"),
fill = list(color = "grey"),
font = list(color = "white"),
align = "center"),
cells = list(values = rbind(top10_df$Pais, top10_df$Total),
align = "center"))
netflix$decada <- floor(netflix$release_year / 10) * 10
por_decada <- as.data.frame(table(decada = netflix$decada, type = netflix$type),
stringsAsFactors = FALSE)
por_decada$decada <- as.numeric(por_decada$decada)
series <- subset(por_decada, type == "TV Show")
filmes <- subset(por_decada, type == "Movie")
plot_ly() %>%
add_trace(x = series$decada, y = series$Freq, name = "TV Series",
type = "scatter", mode = "lines+markers",
line = list(color = "blue"), marker = list(color = "blue")) %>%
add_trace(x = filmes$decada, y = filmes$Freq, name = "Movies",
type = "scatter", mode = "lines+markers",
line = list(color = "yellow"), marker = list(color = "yellow")) %>%
layout(title = "Quantidade de conteúdo por década",
xaxis = list(title = "Década"),
yaxis = list(title = "Qnd. Conteúdo"))
filmes_2000 <- subset(netflix, type == "Movie" &
release_year >= 2000 & release_year <= 2010)
filmes_2000$genero <- trimws(sub(",.*", "", filmes_2000$listed_in))
generos <- c("Dramas", "Action & Adventure", "Comedies")
tab <- table(factor(filmes_2000$release_year, levels = 2000:2010),
factor(filmes_2000$genero, levels = generos))
anos <- as.numeric(rownames(tab))
plot_ly(x = anos, y = tab[, "Dramas"], name = "Drama", type = "bar") %>%
add_trace(y = tab[, "Action & Adventure"], name = "Ação e Aventura") %>%
add_trace(y = tab[, "Comedies"], name = "Comédia") %>%
layout(barmode = "group",
title = "Filmes lançados por gênero (2000-2010)",
xaxis = list(title = "Ano de Lançamento"),
yaxis = list(title = "Qnt. de Lançamentos"))