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)
plot(clock, MRT_1F, pch= 4, col = "red", type= "o",
xlab="Time between Things requests (seconds)", ylab="Response Time (sec.)")
lines(clock, MRT_3F, pch= 6, col = "blue", type= "o")
lines(clock, MRT_5F, pch= 1, col = "yellow", type= "o")
lines(clock, MRT_10F, pch= 2, col = "green", type= "o")
lines(clock, MRT_15F, pch= 5, col = "pink", type= "o")
lines(clock, MRT_sem_F, pch= 3, col = "purple", type= "o")
legend("topright", pch= c(4,6,1,2,5,3), col=c("red","blue","yellow","green","pink","purple" ),legend=c("1 Fog", "3 Fogs", "5 Fogs", "10 Fogs", "15 Fogs", "w/o Fogs"))

layout(matrix(c(1, 2,
3, 4,
5, 0), nr=3, byrow=TRUE))
# Dividindo a tela em colunas e linhas
layout( matrix(1:6, ncol = 2) )
# Vetor de cores
colors = c("#E6E6E6", "#666666")
barplot(t(data.frame(MRT_sem_F, MRT_1F)), names.arg = clock, xlab = "Time between Things requests", ylab ="Response Time (s)",col = colors,beside = T, yaxt="n", log = "y")
# Configurando as marcações para eixo y
axis(side = 2, at = c(1,5,50,500.0), las=2)
legend("topright", pch = c(15, 15), col = colors, legend = c("w/o Fog", "1 Fog"))
barplot(t(data.frame(MRT_sem_F, MRT_5F)), names.arg = clock, xlab = "Time between Things requests", ylab ="Response Time (s)",col = colors,beside = T, yaxt="n", log = "y")
axis(side = 2, at = c(0.5,5.0,50.0), las=2)
legend("topright", pch = c(15, 15), col = colors, legend = c("w/o Fog", "5 Fog"))
barplot(t(data.frame(MRT_sem_F, MRT_15F)), names.arg = clock, xlab = "Time between Things requests", ylab ="Response Time (s)",col = colors,beside = T, yaxt="n", log = "y")
axis(side = 2, at = c(0.2,1.0,5.0), las=2)
legend("topright", pch = c(15, 15), col = colors, legend = c("w/o Fog", "15 Fog"))
barplot(t(data.frame(MRT_sem_F, MRT_3F)), names.arg = clock, xlab = "Time between Things requests", ylab ="Response Time (s)",col = colors,beside = T, yaxt="n", log = "y")
axis(side = 2, at = c(0.5,5.0,50.0), las=2)
legend("topright", pch = c(15, 15), col = colors, legend = c("w/o Fog", "3 Fog"))
barplot(t(data.frame(MRT_sem_F, MRT_10F)), names.arg = clock, xlab = "Time between Things requests", ylab ="Response Time (s)",col = colors,beside = T, yaxt="n", log = "y")
axis(side = 2, at = c(0.2,1.0,5.0), las=2)
legend("topright", pch = c(15, 15), col = colors, legend = c("w/o Fog", "10 Fog"))

Questão 2
colors<-c("red","blue","yellow")
qualit<-c("$0-19","$20-29","$30-39", "$40-49")
good <- c(53.8, 33.9, 2.6, 0)
veryg <- c(43.6, 54.2, 60.5, 21.4)
excell <- c(2.6, 11.9, 36.8, 78.6)
ds <- t(data.frame(good, veryg, excell))
barplot(ds, xlim=c(0, ncol(ds) + 3), main= "Qualidade das refeições de acordo com o preço", names.arg= qualit, xlab= "Meal prices", ylab="Porcentagem", col= colors)
legend("topright", pch = c(13, 13), col = colors, legend = c("Good", "Very Good", "Excellent"))

Questão 3
airquality$celcius <- with(airquality, (Temp - 32) / 1.8)
aux <- subset(airquality, Month == 5, celcius)
temperatura<-aux$celcius
hist(temperatura, col=c(rainbow(8)), probability= T, main="Histograma de Temperatura",xlab= "Temperatura em graus celcius", ylab= "Densidade")
densityTemp<-density(temperatura)
lines(densityTemp)

Questão 4
sales <- read.table("https://training-course-material.com/images/8/8f/Sales.txt",header=TRUE)
pct<-round( sales$SALES/sum(sales$SALES)*100 )
lbls1<-paste(pct,"%",sep="")
lbls2<-paste(sales$COUNTRY,lbls1,sep=" ")
pie(sales$SALES,lbls2, main="Gráfico de vendas",col=rainbow(6))
legend("topright", legend=sales$COUNTRY, cex=0.8, fill=rainbow(length(sales$COUNTRY)))

Questão 5
boxplot(InsectSprays$count~InsectSprays$spray, data=mtcars, xlab="Tipo de spray", ylab="Quantidade de insetos",main="Spray de inseto", range=0, col="yellow")

Questão 6
setwd("C:/Users/hugo.costa/OneDrive - Casa Orange/R Curso")
m0.1 <- read.csv(file="monitoringCloudData_0.1.csv",header=T)
m0.5 <- read.csv(file="monitoringCloudData_0.5.csv",header=T)
m1 <- read.csv(file="monitoringCloudData_1.csv",header=T)
mNone <- read.csv(file="monitoringCloudData_NONE.csv",header=T)
m0.1$currentTime<-as.POSIXlt(m0.1$currentTime)
m0.5$currentTime<-as.POSIXlt(m0.5$currentTime)
m1$currentTime<-as.POSIXlt(m1$currentTime)
mNone$currentTime<-as.POSIXlt(mNone$currentTime)
m0.1$currentTime<-difftime(m0.1$currentTime, min(m0.1$currentTime), units = "hours")
m0.5$currentTime<-difftime(m0.5$currentTime, min(m0.5$currentTime), units = "hours")
m1$currentTime<-difftime(m1$currentTime, min(m1$currentTime), units = "hours")
mNone$currentTime<-difftime(mNone$currentTime, min(mNone$currentTime), units = "hours")
install.packages("dplyr", repos="https://cran.rstudio.com/bin/windows/Rtools/")
## Warning: package 'dplyr' is in use and will not be installed
install.packages("tidyr", repos="https://cran.rstudio.com/bin/windows/Rtools/")
## Installing package into 'C:/Users/hugo.costa/AppData/Local/R/win-library/4.3'
## (as 'lib' is unspecified)
## Warning: unable to access index for repository https://cran.rstudio.com/bin/windows/Rtools/src/contrib:
## não foi possível abrir a URL 'https://cran.rstudio.com/bin/windows/Rtools/src/contrib/PACKAGES'
## Warning: package 'tidyr' is not available for this version of R
##
## A version of this package for your version of R might be available elsewhere,
## see the ideas at
## https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
## Warning: unable to access index for repository https://cran.rstudio.com/bin/windows/Rtools/bin/windows/contrib/4.3:
## não foi possível abrir a URL 'https://cran.rstudio.com/bin/windows/Rtools/bin/windows/contrib/4.3/PACKAGES'
library(tidyr)
## Warning: package 'tidyr' was built under R version 4.3.2
library(dplyr)
m0.1<- m0.1%>%separate (col="usedMemory", into=c("usedMemory", "unidade"), sep= -2)
m0.5<- m0.5%>%separate (col="usedMemory", into=c("usedMemory", "unidade"), sep= -2)
m1<- m1%>%separate (col="usedMemory", into=c("usedMemory", "unidade"), sep= -2)
mNone<- mNone%>%separate (col="usedMemory", into=c("usedMemory", "unidade"), sep= -2)
for (i in 1:length(m0.1$usedMemory)){
if (m0.1[i,"unidade"]=="GB"){
a<- as.integer(m0.1[i,"usedMemory"])
b<-a*1000
b=as.character(b)
m0.1[i,"usedMemory"]<-b
}
}
for (i in 1:length(m1$usedMemory)){
if (m1[i,"unidade"]=="GB"){
a<- as.integer(m1[i,"usedMemory"])
b<-a*1000
b=as.character(b)
m1[i,"usedMemory"]<-b
}
}
for (i in 1:length(m0.5$usedMemory)){
if (m0.5[i,"unidade"]=="GB"){
a<- as.integer(m0.5[i,"usedMemory"])
b<-a*1000
b=as.character(b)
m0.5[i,"usedMemory"]<-b
}
}
for (i in 1:length(mNone$usedMemory)){
if (mNone[i,"unidade"]=="GB"){
a<- as.integer(mNone[i,"usedMemory"])
b<-a*1000
b=as.character(b)
mNone[i,"usedMemory"]<-b
}
}
layout( matrix(1:4, ncol = 2) )
plot (mNone$currentTime,mNone$usedMemory,type = "S", main="Memory Analysis (None Workload)" , xlab="Time (hour)", ylab="Used Memory (MB)",log = "y",yaxt = "n")
axis(side = 2, at = c(96,98,102, 106), las=2)
plot (m0.5$currentTime,m0.5$usedMemory,type = "S", main="Memory Analysis (Workload of 0.5)" , xlab="Time (hour)", ylab="Used Memory (MB)",log = "y",yaxt = "n")
axis(side = 2, at = c(400,800,1200), las=2)
plot (m0.1$currentTime,m0.1$usedMemory,type = "s", main="Memory Analysis (Workload of 0.1)", xlab="Time (hour)", ylab="Used Memory (MB)",log = "y",yaxt = "n")
axis(side = 2, at = c(500,1500,2600, 3500), las=2)
plot (m1$currentTime,m1$usedMemory,type = "S", main="Memory Analysis (Workload of 1.0)", xlab="Time (hour)", ylab="Used Memory (MB)",log = "y", yaxt = "n")
axis(side = 2, at = c(242,246,250, 254), las=2)

Questão 7
Questão 8
Questão 9
netflix <- read.csv("netflix_titles.csv")
netflix <- netflix %>%
mutate(decade = 10 * (floor(release_year/10)))
netflix_count <- netflix %>%
group_by(type, decade) %>%
summarise(count = n()) %>%
ungroup()
## `summarise()` has grouped output by 'type'. You can override using the
## `.groups` argument.
plot <- plot_ly(netflix_count, x = ~decade, y = ~count, color = ~type, type = "scatter", mode = "lines+markers") %>%
layout(title = "Quantidade de conteúdo por década no Netflix",
xaxis = list(title = "Década"),
yaxis = list(title = "Quantidade de conteúdo"))
plot <- plot %>% add_trace(line = list(color = "blue"), name = "Séries") %>%
add_trace(line = list(color = "yellow"), name = "Filmes")
plot
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels
Questão 10