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)
Gráfico de linhas:
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 = 15, 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")
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, 15, 1, 2, 5, 4), lty = 1)
Gráficos de barras (escala log no eixo y):
cores <- c("#E6E6E6", "#666666")
grafico_barras <- function(fog, nome) {
dados <- rbind(MRT_sem_F, fog)
colnames(dados) <- clock
barplot(dados, beside = TRUE, log = "y", col = cores,
xlab = "Time between Things requests",
ylab = "Response time (s)")
legend("topright", legend = c("w/o Fog", nome), fill = cores, cex = 0.8)
}
layout(matrix(c(1, 2, 3, 4, 5, 5), nrow = 3, byrow = TRUE))
grafico_barras(MRT_1F, "1 Fog")
grafico_barras(MRT_3F, "3 Fogs")
grafico_barras(MRT_5F, "5 Fogs")
grafico_barras(MRT_10F, "10 Fogs")
grafico_barras(MRT_15F, "15 Fogs")
layout(1)
tabela <- 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)
rownames(tabela) <- c("Good", "Very Good", "Excellent")
colnames(tabela) <- c("$10-19", "$20-29", "$30-39", "$40-49")
barplot(tabela, col = c("lightblue", "steelblue", "navy"),
main = "Qualidade da refeição por faixa de preço",
xlab = "Preço da refeição", ylab = "Percentual (%)",
xlim = c(0, 6.5),
legend.text = rownames(tabela),
args.legend = list(x = "right", title = "Qualidade"))
maio <- airquality[airquality$Month == 5, ]
maio$Celsius <- (maio$Temp - 32) / 1.8
hist(maio$Celsius, freq = FALSE, col = "steelblue", border = "white",
main = "Temperaturas de maio (airquality)",
xlab = "Temperatura (°C)", ylab = "Densidade")
lines(density(maio$Celsius), col = "red", lwd = 2)
sales <- read.table("https://www.dropbox.com/scl/fi/mpjt4uuqb5vtmfiw38phk/Sales.txt?rlkey=93jlz79xwrrt7ah66d5k403d7&dl=1", header = TRUE)
head(sales)
## COUNTRY SALES
## 1 US 340
## 2 UK 290
## 3 France 510
## 4 Poland 820
## 5 Japan 120
## 6 China 780
# 1ª coluna = país, 2ª coluna = vendas
total <- tapply(sales[, 2], sales[, 1], sum)
porcentagem <- round(total / sum(total) * 100, 1)
cores <- rainbow(length(total))
pie(total, labels = paste0(porcentagem, "%"), col = cores,
main = "Total de vendas por país")
legend("topright", legend = names(total), fill = cores, cex = 0.8)
boxplot(count ~ spray, data = InsectSprays, outline = FALSE, col = "yellow",
main = "Contagem de insetos por inseticida",
xlab = "Inseticida", ylab = "Número de insetos")
Para cada arquivo, deixei o currentTime contínuo em
horas (somando 1 dia quando a hora volta para 00:00) e converti o
usedMemory para MB (1 GB = 1024 MB e 1 TB = 1000000
MB).
nenhuma <- read.csv("monitoringCloudData_NONE.csv")
hora <- sub("^.* ", "", nenhuma$currentTime)
seg <- as.numeric(substr(hora, 1, 2)) * 3600 + as.numeric(substr(hora, 4, 5)) * 60 + as.numeric(substr(hora, 7, 15))
dia <- cumsum(c(0, diff(seg) < 0))
nenhuma$horas <- (seg + dia * 86400 - seg[1]) / 3600
valor <- as.numeric(gsub("[^0-9.]", "", nenhuma$usedMemory))
unidade <- gsub("[0-9.]", "", nenhuma$usedMemory)
nenhuma$memoria <- ifelse(unidade == "GB", valor * 1024, ifelse(unidade == "TB", valor * 1000000, valor))
carga01 <- read.csv("monitoringCloudData_0.1.csv")
hora <- sub("^.* ", "", carga01$currentTime)
seg <- as.numeric(substr(hora, 1, 2)) * 3600 + as.numeric(substr(hora, 4, 5)) * 60 + as.numeric(substr(hora, 7, 15))
dia <- cumsum(c(0, diff(seg) < 0))
carga01$horas <- (seg + dia * 86400 - seg[1]) / 3600
valor <- as.numeric(gsub("[^0-9.]", "", carga01$usedMemory))
unidade <- gsub("[0-9.]", "", carga01$usedMemory)
carga01$memoria <- ifelse(unidade == "GB", valor * 1024, ifelse(unidade == "TB", valor * 1000000, valor))
carga05 <- read.csv("monitoringCloudData_0.5.csv")
hora <- sub("^.* ", "", carga05$currentTime)
seg <- as.numeric(substr(hora, 1, 2)) * 3600 + as.numeric(substr(hora, 4, 5)) * 60 + as.numeric(substr(hora, 7, 15))
dia <- cumsum(c(0, diff(seg) < 0))
carga05$horas <- (seg + dia * 86400 - seg[1]) / 3600
valor <- as.numeric(gsub("[^0-9.]", "", carga05$usedMemory))
unidade <- gsub("[0-9.]", "", carga05$usedMemory)
carga05$memoria <- ifelse(unidade == "GB", valor * 1024, ifelse(unidade == "TB", valor * 1000000, valor))
carga1 <- read.csv("monitoringCloudData_1.csv")
hora <- sub("^.* ", "", carga1$currentTime)
seg <- as.numeric(substr(hora, 1, 2)) * 3600 + as.numeric(substr(hora, 4, 5)) * 60 + as.numeric(substr(hora, 7, 15))
dia <- cumsum(c(0, diff(seg) < 0))
carga1$horas <- (seg + dia * 86400 - seg[1]) / 3600
valor <- as.numeric(gsub("[^0-9.]", "", carga1$usedMemory))
unidade <- gsub("[0-9.]", "", carga1$usedMemory)
carga1$memoria <- ifelse(unidade == "GB", valor * 1024, ifelse(unidade == "TB", valor * 1000000, valor))
head(nenhuma[, c("currentTime", "horas", "usedMemory", "memoria")])
## currentTime horas usedMemory memoria
## 1 2020-01-28 15:37:52.452600 0.00000000 102.94MB 102.94
## 2 2020-01-28 15:38:52.718592 0.01674055 103.36MB 103.36
## 3 2020-01-28 15:39:52.981509 0.03348025 100.23MB 100.23
## 4 2020-01-28 15:40:53.245219 0.05022017 100.19MB 100.19
## 5 2020-01-28 15:41:53.509300 0.06696019 100.12MB 100.12
## 6 2020-01-28 15:42:53.773309 0.08370020 100.01MB 100.01
layout(matrix(1:4, nrow = 2, byrow = TRUE))
plot(nenhuma$horas, nenhuma$memoria, type = "l",
main = "Memory Analysis (None Workload)",
xlab = "Time (hour)", ylab = "Used Memory (MB)")
plot(carga01$horas, carga01$memoria, type = "l",
main = "Memory Analysis (Workload of 0.1)",
xlab = "Time (hour)", ylab = "Used Memory (MB)")
plot(carga05$horas, carga05$memoria, type = "l",
main = "Memory Analysis (Workload of 0.5)",
xlab = "Time (hour)", ylab = "Used Memory (MB)")
plot(carga1$horas, carga1$memoria, type = "l",
main = "Memory Analysis (Workload of 1.0)",
xlab = "Time (hour)", ylab = "Used Memory (MB)")
layout(1)
library(plotly)
netflix <- read.csv("netflix_titles.csv")
# só os títulos com um país (sem vírgula e sem vazio)
um_pais <- netflix[netflix$country != "" & !grepl(",", netflix$country), ]
contagem <- sort(table(um_pais$country), decreasing = TRUE)
top10 <- data.frame(Pais = names(contagem)[1:10],
Total = as.numeric(contagem)[1:10])
plot_ly(top10, labels = ~Pais, values = ~Total, type = "pie",
textinfo = "label+percent") %>%
layout(title = "10 países com mais conteúdo na Netflix")
plot_ly(type = "table",
header = list(values = c("País", "Total de conteúdos"),
fill = list(color = "gray"),
font = list(color = "white"),
align = "center"),
cells = list(values = list(top10$Pais, top10$Total),
align = "center"))
netflix$decada <- floor(netflix$release_year / 10) * 10
tabela_decada <- as.data.frame(table(netflix$decada, netflix$type))
names(tabela_decada) <- c("decada", "tipo", "qtd")
tabela_decada$decada <- as.numeric(as.character(tabela_decada$decada))
series <- tabela_decada[tabela_decada$tipo == "TV Show", ]
filmes <- tabela_decada[tabela_decada$tipo == "Movie", ]
plot_ly() %>%
add_trace(x = series$decada, y = series$qtd, type = "scatter",
mode = "lines+markers", name = "TV Series",
line = list(color = "blue"), marker = list(color = "blue")) %>%
add_trace(x = filmes$decada, y = filmes$qtd, type = "scatter",
mode = "lines+markers", name = "Movies",
line = list(color = "gold"), marker = list(color = "gold")) %>%
layout(title = "Conteúdo da Netflix por década",
xaxis = list(title = "Década"),
yaxis = list(title = "Qtd. Conteúdo"))
Considerei os filmes lançados de 2001 a 2009 e, quando o filme tem
mais de um gênero, só o primeiro da coluna listed_in.
filmes10 <- netflix[netflix$type == "Movie" &
netflix$release_year > 2000 &
netflix$release_year < 2010, ]
filmes10$genero <- trimws(sub(",.*", "", filmes10$listed_in))
filmes10 <- filmes10[filmes10$genero %in% c("Dramas", "Action & Adventure", "Comedies"), ]
tabela_genero <- as.data.frame(table(filmes10$release_year, filmes10$genero))
names(tabela_genero) <- c("ano", "genero", "qtd")
tabela_genero$ano <- as.numeric(as.character(tabela_genero$ano))
drama <- tabela_genero[tabela_genero$genero == "Dramas", ]
acao <- tabela_genero[tabela_genero$genero == "Action & Adventure", ]
comedia <- tabela_genero[tabela_genero$genero == "Comedies", ]
plot_ly() %>%
add_trace(x = drama$ano, y = drama$qtd, type = "bar", name = "Drama") %>%
add_trace(x = acao$ano, y = acao$qtd, type = "bar", name = "Ação e Aventura") %>%
add_trace(x = comedia$ano, y = comedia$qtd, type = "bar", name = "Comédia") %>%
layout(barmode = "group",
title = "Filmes lançados por gênero (2001 a 2009)",
xaxis = list(title = "Ano de Lançamento"),
yaxis = list(title = "Qnt. de Lançamentos"))