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, type="l", col="red", lwd=2,
xlab="Clock", ylab="MRT",
ylim=range(c(MRT_1F, MRT_3F, MRT_5F, MRT_10F, MRT_15F, MRT_sem_F)))
lines(clock, MRT_3F, col="blue", lwd=2)
lines(clock, MRT_5F, col="green", lwd=2)
lines(clock, MRT_10F, col="purple", lwd=2)
lines(clock, MRT_15F, col="orange", lwd=2)
lines(clock, MRT_sem_F, col="brown", lwd=2)
legend("topright",
legend=c("1F", "3F", "5F", "10F", "15F", "sem F"),
col=c("red", "blue", "green", "purple", "orange", "brown"),
lwd=2)
layout_matrix <- matrix(c(1,1,2,2,
3,3,4,4,
5,5,6,6), nrow=3, byrow=TRUE)
layout(layout_matrix)
comparacao_tempo <- function(data1, data_sem_F, title) {
par(mar=c(4.5, 4.5, 3, 2))
heights <- rbind(data1, data_sem_F)
barplot(heights,
beside=TRUE,
col=c("#666666", "#E6E6E6"),
names.arg=clock,
xlab="Time between Things requests",
ylab="Response time (s)",
log="y",
cex.axis=0.8,
cex.names=0.8,
cex.lab=0.9,
main=title)
legend("topright",
legend=c(paste0(strsplit(title, "_")[[1]][1], "_Flag"), "sem_Flag"),
fill=c("#666666", "#E6E6E6"),
bty="n",
cex=0.8)
}
comparacao_tempo(MRT_1F, MRT_sem_F, "1_Flag")
comparacao_tempo(MRT_3F, MRT_sem_F, "3_Flag")
comparacao_tempo(MRT_5F, MRT_sem_F, "5_Flag")
comparacao_tempo(MRT_10F, MRT_sem_F, "10_Flag")
comparacao_tempo(MRT_15F, MRT_sem_F, "15_Flag")
Qualidade de Refeição por Categoria de Preço
data(airquality)
temperaturas_fahrenheit <- airquality$Temp[airquality$Month == 5]
temperaturas_celsius <- (temperaturas_fahrenheit - 32) / 1.8
par(mar = c(5, 5, 4, 2) + 0.1)
hist(temperaturas_celsius,
col = "grey",
main = "Histograma das Temperaturas de Maio (Ce)",
xlab = "Temperatura",
ylab = "Frequência",
probability = TRUE,
labels = TRUE)
lines(density(temperaturas_celsius), col = "blue", lwd = 2)
legend("topright", legend = "Densidade", col = "green", lwd = 2)
vendas_tabela <- "https://training-course-material.com/images/8/8f/Sales.txt"
vendas <- read.table(vendas_tabela, header = TRUE)
vendas$percent <- vendas$SALES / sum(vendas$SALES) * 100
vendas <- vendas[order(vendas$percent, decreasing = TRUE), ]
pie(vendas$percent,
labels = paste(vendas$COUNTRY, "\n", round(vendas$percent, 1), "%"),
main = "Porcentagem de Vendas por País",
col = rainbow(nrow(vendas)))
legend("topright", legend = paste(vendas$COUNTRY, " - ", round(vendas$percent, 1), "%"),
fill = rainbow(nrow(vendas)), cex = 0.8)
data(InsectSprays)
boxplot(count ~ spray, data = InsectSprays, outline = FALSE, col = "blue",
main = "Contagens de Insetos por Inseticida",
xlab = "Inseticida", ylab = "Contagem de Insetos",
labels = TRUE)
library(plotly)
netflix_data_set <- read.csv("~/Downloads/netflix_titles.csv", stringsAsFactors = FALSE)
netflix_data_set <- netflix_data_set[!is.na(netflix_data_set$country) & !grepl(",", netflix_data_set$country) & netflix_data_set$country != "", ]
country_counts <- table(netflix_data_set$country)
countries <- sort(country_counts, decreasing = TRUE)[1:10]
plot_img <- plot_ly(labels = names(countries), values = as.numeric(countries), type = "pie",
textinfo = "label+percent", hoverinfo = "text",
text = paste(names(countries), "-", countries, "títulos"))
image <- plot_img %>% layout(title = "10 primeiros países com mais títulos únicos na plataforma")
image
library(plotly)
netflix_data_set <- read.csv("~/Downloads/netflix_titles.csv", stringsAsFactors = FALSE)
netflix_data_set <- netflix_data_set[!is.na(netflix_data_set$country) & !grepl(",", netflix_data_set$country) & netflix_data_set$country != "", ]
countries <- table(netflix_data_set$country)
countries <- sort(countries, decreasing = TRUE)[1:10]
plot_img <- plot_ly(
type = 'table',
header = list(
values = c("País", "Total de conteúdos"),
align = c('center', 'center'),
font = list(color = 'white', size = 14),
fill = list(color = 'gray')
),
cells = list(
values = list(names(countries), as.numeric(countries)),
align = c('center', 'center'),
font = list(color = 'black', size = 12),
fill = list(color = c('white', 'lightgray'))
)
)
plot_img
library(plotly)
netflix_data_set_2 <- read.csv("netflix_titles.csv", stringsAsFactors = FALSE)
netflix_data_set_2 <- netflix_data_set_2[!is.na(netflix_data_set_2$release_year) & !is.na(netflix_data_set_2$type), ]
netflix_data_set_2$decade <- floor(netflix_data_set_2$release_year / 10) * 10
movies_data <- netflix_data_set_2[netflix_data_set_2$type == "Movie", ]
tv_shows_data <- netflix_data_set_2[netflix_data_set_2$type == "TV Show", ]
movie_counts <- table(movies_data$decade)
tv_show_counts <- table(tv_shows_data$decade)
df_movies <- data.frame(decade = as.numeric(names(movie_counts)),
count = as.numeric(movie_counts),
type = "Movies")
df_tv_shows <- data.frame(decade = as.numeric(names(tv_show_counts)),
count = as.numeric(tv_show_counts),
type = "TV Shows")
df_combined <- rbind(df_movies, df_tv_shows)
plot_img <- plot_ly() %>%
add_trace(data = df_movies, x = ~decade, y = ~count, type = 'scatter', mode = 'lines+markers',
name = 'Movies', line = list(color = 'orange'), marker = list(color = 'orange')) %>%
add_trace(data = df_tv_shows, x = ~decade, y = ~count, type = 'scatter', mode = 'lines+markers',
name = 'TV Shows', line = list(color = 'blue'), marker = list(color = 'blue')) %>%
layout(title = "Conteúdo por Década na Netflix",
xaxis = list(title = "Década", tickmode = "array"),
yaxis = list(title = "Quantidade de Conteúdo"),
legend = list(title = list(text = 'Tipo de Conteúdo')))
plot_img
library(plotly)
netflix_data_set <- read.csv("netflix_titles.csv", stringsAsFactors = FALSE)
netflix_data_set <- netflix_data_set[!is.na(netflix_data_set$release_year) & !is.na(netflix_data_set$listed_in) & netflix_data_set$type == "Movie", ]
netflix_data_set <- netflix_data_set[netflix_data_set$release_year >= 2000 & netflix_data_set$release_year <= 2010, ]
netflix_data_set$primary_genre <- sapply(strsplit(netflix_data_set$listed_in, ", "), `[`, 1)
generos_interesse <- c("Action & Adventure", "Comedies","Dramas")
filtered_data <- netflix_data_set[netflix_data_set$primary_genre %in% generos_interesse, ]
genero_cnts <- table(filtered_data$release_year, filtered_data$primary_genre)
df_cnts_generos <- as.data.frame(genero_cnts)
colnames(df_cnts_generos) <- c("Ano", "Gênero", "Quantidade")
genero_traducao <- c("Dramas" = "Drama", "Action & Adventure" = "Ação e Aventura", "Comedies" = "Comédia")
df_cnts_generos$Gênero <- genero_traducao[df_cnts_generos$Gênero]
plot_img <- plot_ly(df_cnts_generos, x = ~Ano, y = ~Quantidade, type = 'bar', color = ~Gênero, barmode = 'group',
colors = c("red", "blue", "orange")) %>%
layout(title = "Quantidade de Filmes por Gênero",
xaxis = list(title = "Ano"),
yaxis = list(title = "Qnt de Filmes"),
legend = list(title = list(text = 'Gênero'),
traceorder = 'normal'))
plot_img