install.packages(“ggplot2”)
library(ggplot2)
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)
df <- data.frame(clock, MRT_1F, MRT_3F, MRT_5F, MRT_10F, MRT_15F, MRT_sem_F)
p1 <- ggplot(df, aes(x = clock)) + geom_line(aes(y = MRT_1F, color = “1F”), size = 1) + geom_line(aes(y = MRT_3F, color = “3F”), size = 1) + geom_line(aes(y = MRT_5F, color = “5F”), size = 1) + geom_line(aes(y = MRT_10F, color = “10F”), size = 1) + geom_line(aes(y = MRT_15F, color = “15F”), size = 1) + geom_line(aes(y = MRT_sem_F, color = “Sem_F”), size = 1) + labs(title = “Tempo de resposta médio (MRT) por piso”, x = “Tempo de simulação (horas)”, y = “MRT”) + scale_color_manual(values = c(“1F” = “#E41A1C”, “3F” = “#377EB8”, “5F” = “#4DAF4A”, “10F” = “#FF7F00”, “15F” = “#984EA3”, “Sem_F” = “#FFA500”)) + theme_minimal()
print(p1)
p2 <- ggplot(df, aes(x = clock)) + geom_bar(aes(y = MRT_1F), stat = “identity”, fill = “#E6E6E6”, width = 0.5) + geom_bar(aes(y = MRT_3F), stat = “identity”, fill = “#666666”, width = 0.5) + geom_bar(aes(y = MRT_3F), stat = “identity”, fill = “#E6E6E6”, width = 0.5) + geom_bar(aes(y = MRT_3F), stat = “identity”, fill = “#666666”, width = 0.5) + geom_bar(aes(y = MRT_3F), stat = “identity”, fill = “#E6E6E6”, width = 0.5) + geom_bar(aes(y = MRT_3F), stat = “identity”, fill = “#666666”, width = 0.5) + labs(title = “Tempo de resposta médio (MRT) por piso”, x = “Tempo de simulação (horas)”, y = “MRT”) + scale_y_log10() + theme_minimal()
layout(matrix(c(1,2), nrow = 1))
print(p2)
library(ggplot2)
quality_rating <- c(“Good”, “Very Good”, “Excellent”) price_range <- c(“$10-19”, “$20-29”, “$30-39”, “$40-49”)
percentages <- matrix(c(53.8, 43.6, 2.6, 33.9, 54.2, 60.5, 2.6, 11.9, 36.8, 0, 0, 100), nrow = 3, byrow = TRUE)
df2 <- data.frame(quality_rating = rep(quality_rating, each = length(price_range)), price_range = rep(price_range, times = length(quality_rating)), percentage = as.vector(percentages))
p <- ggplot(df, aes(x = quality_rating, y = percentage, fill = price_range)) + geom_bar(stat = “identity”) + labs(title = “Qualidade da Refeição por Faixa de Preço”, x = “Classificação de Qualidade”, y = “Porcentagem”, fill = “Faixa de Preço”) + theme_minimal()
layout(matrix(1:1, nrow = 1))
print(p)
library(ggplot2)
data(“airquality”)
airquality\(Temp_Celsius <- (airquality\)Temp - 32) / 1.8
temperatura <- ggplot(airquality, aes(x = Temp_Celsius)) + geom_histogram(binwidth = 2, fill = “skyblue”, color = “black”) + geom_density(aes(y = ..count..), color = “red”, size = 1) + labs(title = “Histograma das Temperaturas (Maio)”, x = “Temperatura (°C)”, y = “Contagem”) + theme_minimal()
print(temperatura)
sales <- read.table(“https://training-course-material.com/images/8/8f/Sales.txt”, header = TRUE)
sales\(total_percentage <- sales\)Sales / sum(sales$Sales) * 100
sales <- sales[order(sales$total_percentage, decreasing = TRUE), ]
sales <- sales[order(sales$total_percentage, decreasing = TRUE), ]
slice_colors <- rainbow(nrow(sales))
pie(sales\(Sales, labels = paste(sales\)Country, “(”, round(sales$total_percentage, 2), “%)”), col = slice_colors, main = “Porcentagem de Vendas por País”)
data(InsectSprays)
boxplot(count ~ spray, data = InsectSprays, outline = FALSE, col = “yellow”, main = “Contagens de Insetos por Tipo de Inseticida”, xlab = “Tipo de Inseticida”, ylab = “Contagem de Insetos”)
install.packages(“dplyr”)
library(dplyr) library(ggplot2)
adjust_time <- function(df) { df3 <- df3 %>% mutate(currentTime = as.POSIXct(currentTime, format = “%Y-%m-%d %H:%M:%S”)) df3 <- df3 %>% mutate(currentTime = difftime(currentTime, min(currentTime), units = “hours”)) return(df) }
adjust_memory <- function(df) { df3\(usedMemory <- gsub("TB", "*1000000", df\)usedMemory, fixed = TRUE) df3\(usedMemory <- gsub("GB", "*1024", df\)usedMemory, fixed = TRUE) df3\(usedMemory <- gsub("MB", "", df\)usedMemory, fixed = TRUE) df3\(usedMemory <- as.numeric(df\)usedMemory) return(df) }
data_0.1 <- read.csv(“monitoringCloudData_0.1.csv”) data_0.5 <- read.csv(“monitoringCloudData_0.5.csv”) data_1 <- read.csv(“monitoringCloudData_1.csv”) data_NONE <- read.csv(“monitoringCloudData_NONE.csv”)
data_0.1 <- adjust_time(data_0.1) data_0.1 <- adjust_memory(data_0.1)
data_0.5 <- adjust_time(data_0.5) data_0.5 <- adjust_memory(data_0.5)
data_1 <- adjust_time(data_1) data_1 <- adjust_memory(data_1)
data_NONE <- adjust_time(data_NONE) data_NONE <- adjust_memory(data_NONE)
plot_0.1 <- ggplot(data_0.1, aes(x = currentTime, y = usedMemory)) + geom_line() + labs(title = “0.1”) + xlab(“Tempo”) + ylab(“Memória Usada (MB)”)
plot_0.5 <- ggplot(data_0.5, aes(x = currentTime, y = usedMemory)) + geom_line() + labs(title = “0.5”) + xlab(“Tempo”) + ylab(“Memória Usada (MB)”)
plot_1 <- ggplot(data_1, aes(x = currentTime, y = usedMemory)) + geom_line() + labs(title = “1”) + xlab(“Tempo”) + ylab(“Memória Usada (MB)”)
plot_NONE <- ggplot(data_NONE, aes(x = currentTime, y = usedMemory)) + geom_line() + labs(title = “NONE”) + xlab(“Tempo”) + ylab(“Memória Usada (MB)”)
layout(matrix(c(1, 2, 3, 4), nrow = 2, byrow = TRUE))
print(plot_0.1) print(plot_0.5) print(plot_1) print(plot_NONE)
library(plotly) library(dplyr)
netflix_data <- read.csv(“C:/Users/LABADMIN/Downloads/netflix_titles.csv”, header=TRUE, sep=‘.’)
dados_um_pais <- netflix_data %>% filter(!is.na(“country”)) %>% filter(!grepl(“,”, “country”))
contagem <- dados_um_pais %>% count(“country”) %>% arrange(desc(n))
top_10 <- head(contagem, 10)
plot_ly(labels = ~top_10\(country, values = ~top_10\)n, type = ‘pie’, textinfo = ‘percent+label’, title = ‘Top 10 Países com Mais Conteúdo na Netflix’) %>% layout(showlegend = FALSE)
library(plotly) library(dplyr)
netflix_data <- read.csv(“netflix_titles.csv”)
netflix_data_um_pais <- netflix_data %>% filter(!is.na(country)) %>% filter(!grepl(“,”, country))
cont <- netflix_data_single_country %>% count(country) %>% arrange(desc(n))
top_10_paises <- head(country_counts, 10)
tabela_df <- data.frame(País = top_10_countries\(country, `Total de conteúdos` = top_10_countries\)n)
plot_ly(data = table_df, type = “table”) %>% layout( header =
list( values = list(“País”, “Total de conteúdos”), align = c(“center”,
“center”), fill = list(color = “#444444”), font = list(color = “white”)
), cells = list( values = list(table_df\(País,
table_df\)Total de conteúdos), align = c(“center”),
font = list(color = “black”) ) )
library(plotly) library(dplyr)
netflix_data <- read.csv(“netflix_titles.csv”)
get_decade <- function(year) { decade_start <- as.integer(year / 10) * 10 paste(decade_start, “-”, decade_start + 9) }
netflix_data\(decade <- sapply(netflix_data\)release_year, get_decade)
content_by_decade <- netflix_data %>% group_by(decade, type) %>% summarise(count = n())
plot <- plot_ly(data = content_by_decade, x = ~decade, y = ~count, color = ~type, type = ‘scatter’, mode = ‘lines+markers’) %>% layout(title = “Quantidade de Conteúdo por Década do Netflix”, xaxis = list(title = “Década”), yaxis = list(title = “Quantidade de Conteúdo”), legend = list(title = “Tipo de Conteúdo”))
plot
library(plotly) library(dplyr)
netflix_data <- read.csv(“netflix_titles.csv”)
movies_2000_2010 <- netflix_data %>% filter(type == “Movie” & release_year >= 2000 & release_year <= 2010)
movies_2000_2010\(genre <-
sapply(strsplit(movies_2000_2010\)listed_in, “,”),
[, 1)
movies_genre <- movies_2000_2010 %>% filter(genre %in% c(“Dramas”, “Action & Adventure”, “Comedies”))
genre_count <- movies_genre %>% group_by(release_year, genre) %>% summarise(count = n())
plot <- plot_ly(data = genre_count, x = ~release_year, y = ~count, color = ~genre, type = ‘bar’, barmode = ‘group’) %>% layout(title = “Quantidade de Filmes Lançados por Gênero (2000-2010)”, xaxis = list(title = “Ano”), yaxis = list(title = “Quantidade de Filmes”), legend = list(title = “Gênero”))
plot