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(x = clock, y = MRT_1F,
type = "o",
col = "black",
pch = 4,
xlim = c(0.1,3),
ylim = c(0,550),
xlab = "Time between Things requests (seconds)",
ylab = "Response Time (Sec.)",
)
lines(clock, MRT_3F, type="o", pch=11, 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", pch = c(4,11,1,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"))
layout(matrix(c(1, 2,
3, 4,
5, 6), nrow=3, byrow=TRUE))
values <- rbind(MRT_sem_F,MRT_1F)
barplot(
values,
beside = TRUE,
log = "y",
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 Fog"))
values <- rbind(MRT_sem_F,MRT_3F)
barplot(
values,
beside = TRUE,
log = "y",
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"))
values <- rbind(MRT_sem_F,MRT_5F)
barplot(
values,
beside = TRUE,
log = "y",
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"))
values <- rbind(MRT_sem_F,MRT_10F)
barplot(
values,
beside = TRUE,
log = "y",
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"))
values <- rbind(MRT_sem_F,MRT_15F)
barplot(
values,
beside = TRUE,
log = "y",
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"))
price <- c("10-19$","20-39$","30-39$","40-49$")
good <- c(53.8, 33.9, 2.6, 0)
very <- c(43.6, 54.2, 60.5, 21.4)
excel <- c(2.6, 11.9, 36.8, 78.6)
mat <- rbind(good,very,excel)
par(mar = c(5.1, 4.1, 4.1, 10.1), xpd=TRUE)
barplot(mat,
names.arg = price,
col = c("azure3","cyan3","olivedrab3"),
xlab = "Meal Price",
ylab = "Quality Rating",
main = "Quality x Price")
legend("topright",
inset=c(-0.25,0),
fill = c("azure3","cyan3","olivedrab3"),
legend = c("Good", "Very Good","Excellent"))
df <- airquality
df$Temp <- (df$Temp-32)/1.8
Temperature <- df$Temp[df$Month==5]
hist(Temperature,
main = "Histogram of temperature",
col = "gray",
freq = FALSE
)
densityTemp <- density(Temperature)
lines(densityTemp)
sales <-read.table("https://training-course-material.com/images/8/8f/Sales.txt",header=TRUE)
labels <- sales$COUNTRY
pct <- round(sales$SALES/sum(sales$SALES)*100)
lbls <- paste(labels,pct)
lbls <- paste(lbls,"%",sep="")
pie(x = sales$SALES,
main = "Sales by country",
labels = lbls,
col = rainbow(6)
)
legend("topleft",
cex = 0.8,
legend = labels,
fill = rainbow(6))
df <- InsectSprays
boxplot(df$count ~ df$spray,
xlab = "Spray type",
ylab = "Insect count",
main = "Effectiveness of Insect Sprays",
outline = FALSE,
col = "yellow"
)
Fico devendo, pode avançar para a próxima.
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.2.1 ✔ readr 2.2.0
## ✔ forcats 1.0.1 ✔ stringr 1.6.0
## ✔ ggplot2 4.0.3 ✔ tibble 3.3.1
## ✔ lubridate 1.9.5 ✔ tidyr 1.3.2
## ✔ purrr 1.2.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(plotly)
##
## Anexando pacote: 'plotly'
##
## O seguinte objeto é mascarado por 'package:ggplot2':
##
## last_plot
##
## O seguinte objeto é mascarado por 'package:stats':
##
## filter
##
## O seguinte objeto é mascarado por 'package:graphics':
##
## layout
df<- read.csv("C:/Workspace/plot_exercises/netflix_titles.csv")
df[df==""] <- NA
top10 <- df %>%
filter(!is.na(country)) %>%
count(country, sort = TRUE) %>%
slice_head(n = 10)
plotly::plot_ly(data=top10,values=~n,labels=~factor(country),
marker=list(colors=rainbow(10)),
type="pie") %>% layout(title="Top 10 Countries")
fig <- plot_ly(
type = 'table',
columnwidth = c(100, 100),
columnorder = c(0, 1),
header = list(
values = c("País","Total de 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(top10$country, top10$n),
align = c("center", "center"),
line = list(color = "black", width = 1),
font = list(family = "Arial", size = 12, color = c("black"))
))
fig
df_decada <- df %>%
filter(type %in% c("Movie", "TV Show")) %>%
mutate(decade = floor(release_year / 10) * 10) %>%
group_by(decade, type) %>%
summarise(qtd = n(), .groups = "drop")
decades <- sort(unique(df_decada$decade))
fig <- plot_ly(df_decada,
x = ~decade,
y = ~qtd,
color = ~type,
colors = c("Movie" = "yellow",
"TV Show" = "blue"),
type = "scatter",
mode = "lines+markers")
fig <- fig %>%
layout(
title = "Amount of content by decade - Netflix",
xaxis = list(
title = "Decades",
tickmode = "array",
tickvals = decades,
tickangle = 60
),
yaxis = list(title = "Amount of content")
)
fig
genres_df <- df %>%
filter(between(release_year, 2000, 2010)) %>%
mutate(
listed_in = str_trim(str_extract(listed_in, "^[^,]+"))
) %>%
filter(listed_in %in% c(
"Dramas",
"Action & Adventure",
"Comedies"
)) %>%
count(release_year, listed_in)
fig <- plot_ly(
genres_df,
x = ~release_year,
y = ~n,
color = ~listed_in,
colors = c(
"Dramas" = "blue",
"Action & Adventure" = "red",
"Comedies" = "green"
),
type = "bar"
)
fig