#2VA
deaths <- VADeaths
ruralMale <- deaths[,'Rural Male']
ruralFemale <- deaths[,'Rural Female']
urbanMale <- deaths[,'Urban Male']
urbanFemale <- deaths[,'Urban Female']
categories <- c('50-54', '55-59', '60-64', '65-69', '70-74')
colors <- c('blue', 'red', 'green', 'yellow')
death_matrix <- matrix(c(
ruralMale,
ruralFemale,
urbanMale,
urbanFemale
), nrow = 4, ncol=5, byrow = TRUE)
barplot(death_matrix, col = colors, names.arg = categories,
main = "VADeaths",
xlab = "Age group", ylab = "Death Rates")
legend("topleft", pch = c(15,15,15), legend = c("Rural Male", "Rural Female", "Urban Male", "Urban Female"), col= colors)
estagios_doenca <- c(
"moderado", "leve", "leve", "severo", "leve",
"moderado", "moderado", "moderado", "leve", "leve",
"severo", "leve", "moderado", "moderado", "leve",
"severo", "moderado", "moderado", "moderado", "leve"
)
frequencias <- table(estagios_doenca)
percentuais <- (frequencias / length(estagios_doenca)) * 100
labels <- paste(percentuais,"%",sep="")
pie(frequencias, labels, main = "Estagios doenca", col = rainbow(length(frequencias)))
legend("topleft", legend = c('leve', 'moderado','severo'), fill = rainbow(length(frequencias)))
chooseCRANmirror(graphics=FALSE, ind=1)
install.packages("tm")
## Installing package into 'C:/Users/Victor Olimpio/AppData/Local/R/win-library/4.3'
## (as 'lib' is unspecified)
## package 'tm' successfully unpacked and MD5 sums checked
## Warning: cannot remove prior installation of package 'tm'
## Warning in file.copy(savedcopy, lib, recursive = TRUE): problem copying
## C:\Users\Victor
## Olimpio\AppData\Local\R\win-library\4.3\00LOCK\tm\libs\x64\tm.dll to
## C:\Users\Victor Olimpio\AppData\Local\R\win-library\4.3\tm\libs\x64\tm.dll:
## Permission denied
## Warning: restored 'tm'
##
## The downloaded binary packages are in
## C:\Users\Victor Olimpio\AppData\Local\Temp\RtmpOaSAEu\downloaded_packages
install.packages("wordcloud")
## Installing package into 'C:/Users/Victor Olimpio/AppData/Local/R/win-library/4.3'
## (as 'lib' is unspecified)
## package 'wordcloud' successfully unpacked and MD5 sums checked
## Warning: cannot remove prior installation of package 'wordcloud'
## Warning in file.copy(savedcopy, lib, recursive = TRUE): problem copying
## C:\Users\Victor
## Olimpio\AppData\Local\R\win-library\4.3\00LOCK\wordcloud\libs\x64\wordcloud.dll
## to C:\Users\Victor
## Olimpio\AppData\Local\R\win-library\4.3\wordcloud\libs\x64\wordcloud.dll:
## Permission denied
## Warning: restored 'wordcloud'
##
## The downloaded binary packages are in
## C:\Users\Victor Olimpio\AppData\Local\Temp\RtmpOaSAEu\downloaded_packages
install.packages("NLP")
## Installing package into 'C:/Users/Victor Olimpio/AppData/Local/R/win-library/4.3'
## (as 'lib' is unspecified)
## package 'NLP' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\Victor Olimpio\AppData\Local\Temp\RtmpOaSAEu\downloaded_packages
install.packages("ggplot2")
## Installing package into 'C:/Users/Victor Olimpio/AppData/Local/R/win-library/4.3'
## (as 'lib' is unspecified)
## package 'ggplot2' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\Victor Olimpio\AppData\Local\Temp\RtmpOaSAEu\downloaded_packages
install.packages('RColorBrewer')
## Installing package into 'C:/Users/Victor Olimpio/AppData/Local/R/win-library/4.3'
## (as 'lib' is unspecified)
## package 'RColorBrewer' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\Victor Olimpio\AppData\Local\Temp\RtmpOaSAEu\downloaded_packages
install.packages("Matrix")
## Installing package into 'C:/Users/Victor Olimpio/AppData/Local/R/win-library/4.3'
## (as 'lib' is unspecified)
## package 'Matrix' successfully unpacked and MD5 sums checked
## Warning: cannot remove prior installation of package 'Matrix'
## Warning in file.copy(savedcopy, lib, recursive = TRUE): problem copying
## C:\Users\Victor
## Olimpio\AppData\Local\R\win-library\4.3\00LOCK\Matrix\libs\x64\Matrix.dll to
## C:\Users\Victor
## Olimpio\AppData\Local\R\win-library\4.3\Matrix\libs\x64\Matrix.dll: Permission
## denied
## Warning: restored 'Matrix'
##
## The downloaded binary packages are in
## C:\Users\Victor Olimpio\AppData\Local\Temp\RtmpOaSAEu\downloaded_packages
library(Matrix)
library(RColorBrewer)
library(NLP)
library(tm)
library(wordcloud)
library(ggplot2)
##
## Attaching package: 'ggplot2'
## The following object is masked from 'package:NLP':
##
## annotate
gpt <- read.csv("ChatGPT.csv")
Encoding(gpt$text) <- "UTF-8"
corpus <- Corpus(VectorSource(gpt$text))
corpus <- tm_map(corpus, content_transformer(tolower))
## Warning in tm_map.SimpleCorpus(corpus, content_transformer(tolower)):
## transformation drops documents
corpus <- tm_map(corpus, removePunctuation)
## Warning in tm_map.SimpleCorpus(corpus, removePunctuation): transformation drops
## documents
corpus <- tm_map(corpus, removeNumbers)
## Warning in tm_map.SimpleCorpus(corpus, removeNumbers): transformation drops
## documents
corpus <- tm_map(corpus, removeWords, stopwords("portuguese"))
## Warning in tm_map.SimpleCorpus(corpus, removeWords, stopwords("portuguese")):
## transformation drops documents
corpus <- tm_map(corpus, stripWhitespace)
## Warning in tm_map.SimpleCorpus(corpus, stripWhitespace): transformation drops
## documents
dtm <- DocumentTermMatrix(corpus)
freq_terms <- colSums(as.matrix(dtm))
freq_terms <- sort(freq_terms, decreasing = TRUE)
palavra_mais_frequente <- names(which.max(freq_terms))
corpus <- tm_map(corpus, removeWords, palavra_mais_frequente)
## Warning in tm_map.SimpleCorpus(corpus, removeWords, palavra_mais_frequente):
## transformation drops documents
top_words <- head(freq_terms, 20)
barplot(top_words, main = "Palavras mais frequentes em #ChatGPT Tweets",
, ylab = "Frequência", col = "blue", las = 2)
wordcloud(corpus, min.freq = 1, max.words=60, random.order=F, rot.per=0.35, colors=brewer.pal(8, "Dark2"))
flu <- read.csv("flu.csv")
hist(flu$age, prob = TRUE, main = "Histograma da Idade das Mortes", col = 'lightgreen', xlab = "Idade", ylab = "Frequencia")
lines(density(flu$age), col = "darkgreen", lwd = 2)
n <- 35
repeticoes <- 200
medias_amostrais <- replicate(repeticoes, mean(rnorm(n)))
hist(medias_amostrais,prob = TRUE, main = "Medias amostrais",col = 'lightblue', xlab = "Idade", ylab = "Frequencia")
lines(density(medias_amostrais), col = "darkblue", lwd = 2)