Visualização de Dados
Questão 1
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)
## a
plot(clock, MRT_1F, pch=4, type="o", cex=2, col="black", ylab = "Response Time (sec)", xlab = "Time between requests (seconds)" ,xlim=c(0,3.0), ylim=c(0,500))
lines(clock, MRT_3F, type = "o", col="yellow", pch=11)
lines(clock, MRT_5F, type = "o", col="red", pch=21)
lines(clock, MRT_10F, type = "o", col="blue", pch=2)
lines(clock, MRT_15F, type = "o", col="purple", pch=5)
lines(clock, MRT_sem_F, type = "o", col="green", pch=4)
legend("topright", pch = c(4,11,21,2,5,4), col = c("black", "yellow", "red", "blue", "purple", "green"), legend = c("1 Fog", "3 Fogs", "5 Fogs", "10 Fogs", "15 Fogs", "w/o Fog"),
lwd = 1)

## b
par(mfrow = c(3,2))
values1 <- matrix(c(MRT_sem_F, MRT_1F), nrow = 2, ncol=7, byrow = TRUE)
barplot(values1,log = "y", beside = TRUE, col = c("#E6E6E6", "#666666"), names.arg = clock, xlab = "Time between Things requests", ylab= "Response time (s)")
legend("topright", pch = c(15,15), col = c("#E6E6E6", "#666666"), legend = c( "w/o Fog", "1 Fogs"))
values3 <- matrix(c(MRT_sem_F, MRT_3F), nrow = 2, ncol=7, byrow = TRUE)
barplot(values3,log = "y", beside = TRUE, col = c("#E6E6E6", "#666666"), names.arg = clock, xlab = "Time between Things requests", ylab= "Response time (s)")
legend("topright", pch = c(15,15), col = c("#E6E6E6", "#666666"), legend = c( "w/o Fog", "3 Fogs"))
values5 <- matrix(c(MRT_sem_F, MRT_5F), nrow = 2, ncol=7, byrow = TRUE)
barplot(values5,log = "y", beside = TRUE, col = c("#E6E6E6", "#666666"), names.arg = clock, xlab = "Time between Things requests", ylab= "Response time (s)")
legend("topright", pch = c(15,15), col = c("#E6E6E6", "#666666"), legend = c( "w/o Fog", "5 Fogs"))
values10 <- matrix(c(MRT_sem_F, MRT_10F), nrow = 2, ncol=7, byrow = TRUE)
barplot(values10,log = "y", beside = TRUE, col = c("#E6E6E6", "#666666"), names.arg = clock, xlab = "Time between Things requests", ylab= "Response time (s)")
legend("topright", pch = c(15,15), col = c("#E6E6E6", "#666666"), legend = c( "w/o Fog", "10 Fogs"))
values15 <- matrix(c(MRT_sem_F, MRT_15F), nrow = 2, ncol=7, byrow = TRUE)
barplot(values15, log = "y", beside = TRUE, col = c("#E6E6E6", "#666666"), names.arg = clock, xlab = "Time between Things requests", ylab= "Response time (s)")
legend("topright", pch = c(15,15), col = c("#E6E6E6", "#666666"), legend = c( "w/o Fog", "15 Fogs"))

Questão 2
categorias <- c("$10-19", "$20-29", "$30-39", "$40-49")
good <- c(53.8, 33.9, 2.6, 0.0)
veryGood <- c(43.6, 54.2, 60.5, 21.4)
excellent <- c(2.6, 11.9, 36.8, 78.6)
dados <- matrix(c(
good,
veryGood,
excellent
), nrow = 3, ncol=4,byrow=TRUE)
barplot(dados, col = c("#E6E6E6", "#CCCCCC", "#999999"),
main = "Gráfico de Barras Empilhadas",
names.arg = categorias,
xlab = "Categorias", ylab = "Valores")
legend("topright", pch = c(15,15,15), legend = c("Good", "Very Good", "Excellent"),col=c("#E6E6E6", "#CCCCCC", "#999999"))

Questão 3
temp <- subset(airquality, airquality$Month == 5)
temp <- (temp$Temp -32)/1.8
hist(temp, col = "#00a8ff", freq = FALSE, probability = T, main = "Temperaturas no mes de maio", xlab = "Temperatura (°C)", ylab = "Desnsidade")
densityTemp <- density(temp)
lines(densityTemp)

Questão 4
sales <- read.table("https://training-course-material.com/images/8/8f/Sales.txt",header=TRUE)
lbls <- c(sales$COUNTRY)
percent <- c(sales$SALES)
percentuais <- round(percent/sum(percent)*100)
labels <- paste(percentuais,"%",sep="")
pie(percent, labels, main = "Total de vendas por país", col = rainbow(length(percent)))
legend("topleft", legend = lbls, cex = 0.8, fill = rainbow(length(percent)))

Questão 5
boxplot(count ~ spray, data = InsectSprays, outline = FALSE , col="yellow", xlab = "Inseticidas", ylab = "Contagem de insetos", main="Contagen de insetos em unidades experimentais agrícolas")

Questão 6
loud01 <- read.csv(file="monitoringCloudData_0.1.csv", header = T, strip.white = T, na.strings = "")
loud05 <- read.csv(file="monitoringCloudData_0.5.csv", header = T, strip.white = T, na.strings = "")
loud1 <- read.csv(file="monitoringCloudData_1.csv", header = T, strip.white = T, na.strings = "")
loudNone <- read.csv(file="monitoringCloudData_NONE.csv", header = T, strip.white = T, na.strings = "")
library(stringr)
converter_para_MB <- function(valor) {
numero <- as.numeric(str_extract(valor, "\\d+"))
unidade <- str_extract(valor, "[A-Za-z]+")
if (grepl("KB", unidade, ignore.case = TRUE)) {
return(numero / 1024)
} else if (grepl("GB", unidade, ignore.case = TRUE)) {
return(numero * 1024)
} else if (grepl("TB", unidade, ignore.case = TRUE)) {
return(numero * 1024 * 1024)
} else {
return(numero)
}
}
tempo_continuo <- function(tempo_string) {
tempo_obj <- as.POSIXct(tempo_string, format = "%Y-%m-%d %H:%M:%OS")
return(tempo_obj)
}
par(mfrow = c(2,2))
## loudNone
loudNone$usedMemoryMB <- sapply(loudNone$usedMemory, converter_para_MB)
loudNone$difTime <- sapply(loudNone$currentTime, tempo_continuo)
usedMemoryMB <- loudNone$usedMemoryMB
difTime <- loudNone$difTime
data <- data.frame(usedMemoryMB, difTime)
plot(difTime, usedMemoryMB, type="l", pch = 0, cex=1, col="black", main = "Memory Analysis (None Workload)", ylab = "Used Memory (MB)", xlab = "Time (hour)" )
## loud0.1
loud01$usedMemoryMB <- sapply(loud01$usedMemory, converter_para_MB)
loud01$difTime <- sapply(loud01$currentTime, tempo_continuo)
usedMemoryMB01 <- loud01$usedMemoryMB
difTime01 <- loud01$difTime
plot(difTime01, usedMemoryMB01, type="l", pch = 0, cex=1, col="black", main = "Memory Analysis (Workload of 0.1)", ylab = "Used Memory (MB)", xlab = "Time (hour)" )
## loud0.5
loud05$usedMemoryMB <- sapply(loud05$usedMemory, converter_para_MB)
loud05$difTime <- sapply(loud05$currentTime, tempo_continuo)
usedMemoryMB <- loud05$usedMemoryMB
difTime <- loud05$difTime
data <- data.frame(usedMemoryMB, difTime)
plot(difTime, usedMemoryMB, type="l", pch = 0, cex=1, col="black", main = "Memory Analysis (Workload of 0.5)", ylab = "Used Memory (MB)", xlab = "Time (hour)" )
## loud1
loud1$usedMemoryMB <- sapply(loud1$usedMemory, converter_para_MB)
loud1$difTime <- sapply(loud1$currentTime, tempo_continuo)
usedMemoryMB <- loud1$usedMemoryMB
difTime <- loud1$difTime
data <- data.frame(usedMemoryMB, difTime)
plot(difTime, usedMemoryMB, type="l", pch = 0, cex=1, col="black", main = "Memory Analysis (Workload of 1.0)", ylab = "Used Memory (MB)", xlab = "Time (hour)" )

Questão 7
chooseCRANmirror(graphics=FALSE, ind=1)
library(dplyr)
install.packages("plotly")
## package 'plotly' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\victor.silva\AppData\Local\Temp\RtmpaiyaZv\downloaded_packages
library(plotly)
netflix <- read.csv(file="netflix_titles.csv", header = T, strip.white = T, na.strings = "")
dados_filtrados <- netflix[grep(",", netflix$country, invert = TRUE), ]
orderCountries <- dados_filtrados %>% group_by(country) %>% summarise( Content = sum(length(title), ma.rm = TRUE )) %>% arrange(desc(Content))
orderCountries <- slice(filter(orderCountries, !(is.na(country))), 1:10)
fig <- plot_ly(orderCountries, labels=~country, values=~Content, type = 'pie')
fig
Questão 8
fig <- plot_ly(
type = 'table',
columnwidth = c(100, 100),
columnorder = c(0, 1),
header = list(
values = c("Países", "Conteúdos"),
align = c("center", "center"),
line = list(width = 1, color = 'black'),
fill = list(color = c("grey", "grey")),
font = list(family = "Arial", size = 14, color = "white")
),
cells = list(
values = rbind(orderCountries$country, orderCountries$Content),
align = c("center", "center"),
line = list(color = "black", width = 1),
font = list(family = "Arial", size = 12, color = c("black"))
))
fig
Questão 9
decadas_data <- netflix %>%
mutate(decada = floor(release_year / 10) * 10) %>%
group_by(decada, type) %>%
summarise(Quantidade = n())
series <- filter(decadas_data, type != "Movie")
movies <- filter(decadas_data, type == "Movie")
line <- plot_ly(data = data.frame(series), x= ~decada, y= ~Quantidade,type = "scatter", mode = "lines+markers", line = list(color = "blue"), name = "TV Series" )
line <- line %>% add_trace(data = data.frame(movies), x= ~decada, y= ~Quantidade, type = "scatter", mode = "lines+markers", line = list(color = "orange"), name = "Movies" )
line <- line %>% layout(
xaxis = list(title = "Década"),
yaxis = list(title = "Quantidade de Produções"))
line