2 VA de CAD

VADeaths

V<-data.frame(VADeaths)
ncol<-4
nrow<-5
colors = c("green","orange","red","blue","yellow")
x<-names(V)
y<-row.names(V)
vetor<-as.numeric(c(V[1,],V[2,],V[3,],V[4,],V[5,]))
regions <- c("East","West","North")
# Criar a matriz dos valores
Values <-
  matrix((vetor), nrow = nrow, ncol = ncol, byrow
         = TRUE)
barplot(Values, main = "Death Rates in Virginia (1940)", names.arg = x,
          xlab = "Population Group", ylab =
            "Age Group", col = colors,
          beside = T,ylim=c(0,100))

legend("topright", pch=c(15,15,15), col =
         colors, legend=y)

ClassificaçãoDoença

V<-c('moderado', 'leve', 'leve', 'severo', 'leve', 'moderado', 'moderado','moderado', 'leve', 'leve', 'severo','leve', 'moderado', 'moderado', 'leve', 'severo', 'moderado', 'moderado','moderado','leve')
l<-length(V[V=="leve"])
m<-length(V[V=="moderado"])
s<-length(V[V=="severo"])
colors<-c("green","red","blue")
x <- c(l,m,s)
labels<-c("leve", "moderado","severo")
pct <- round(x/sum(x)*100)
lbls <- paste(labels, pct, sep=" = ")
lbls <- paste(lbls,"%",sep="")
Titulo="Estagios de Classificacao de Doenca"
pie(x,labels=lbls, main=Titulo,col=colors,radius = 1.05)

legend("topright",legend=labels,cex=0.75, fill=colors)

Twitter

V<-read.csv("ChatGPT.csv")
V <- paste(V$text, collapse = " ")
corpus <- tm::Corpus(tm::VectorSource(V))
#tm::inspect(corpus)

corpus <- tm::tm_map(corpus, tm::removeNumbers)
## Warning in tm_map.SimpleCorpus(corpus, tm::removeNumbers): transformation drops
## documents
corpus <- tm::tm_map(corpus, tolower)
## Warning in tm_map.SimpleCorpus(corpus, tolower): transformation drops documents
corpus <- tm::tm_map(corpus, tm::removePunctuation)
## Warning in tm_map.SimpleCorpus(corpus, tm::removePunctuation): transformation
## drops documents
corpus <- tm::tm_map(corpus, tm::stripWhitespace)
## Warning in tm_map.SimpleCorpus(corpus, tm::stripWhitespace): transformation
## drops documents
corpus <- tm::tm_map(corpus, tm::removeWords, tm::stopwords('portuguese'))
## Warning in tm_map.SimpleCorpus(corpus, tm::removeWords,
## tm::stopwords("portuguese")): transformation drops documents
removeURL <- function(x) gsub("http[^[:space:]]*", "", x)
corpus <- tm::tm_map(corpus, removeURL)
## Warning in tm_map.SimpleCorpus(corpus, removeURL): transformation drops
## documents
removeNumPunct <- function(x) gsub("[^[:alpha:][:space:]]*", "", x)
corpus <- tm::tm_map(corpus, tm::content_transformer(removeNumPunct))
## Warning in tm_map.SimpleCorpus(corpus,
## tm::content_transformer(removeNumPunct)): transformation drops documents

Matriz de Palavras:

tdm <- as.matrix(tm::TermDocumentMatrix(corpus))
fre <- sort(rowSums(tdm),decreasing=TRUE)

Parte 1

#Plotar Gráficos de Barras dos Termos Mais Frequentes
#Pegar palavras com frequência maior que 2
aux<-subset(fre, fre>25)
barplot(aux, las=2, col = rainbow(10))

Parte 2:

#Gerar Nuvem de Palavras

corpus<-gsub("chatgpt","",corpus)

wordcloud::wordcloud(corpus, min.freq = 1, max.words=60,
          random.order=FALSE, rot.per=0.15,
          colors=RColorBrewer::brewer.pal(8, "Dark2"))
## Warning in tm_map.SimpleCorpus(corpus, tm::removePunctuation): transformation
## drops documents
## Warning in tm_map.SimpleCorpus(corpus, function(x) tm::removeWords(x,
## tm::stopwords())): transformation drops documents
## Warning in wordcloud::wordcloud(corpus, min.freq = 1, max.words = 60,
## random.order = FALSE, : compreenda could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(corpus, min.freq = 1, max.words = 60,
## random.order = FALSE, : estrangeiros could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(corpus, min.freq = 1, max.words = 60,
## random.order = FALSE, : researchgpt could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(corpus, min.freq = 1, max.words = 60,
## random.order = FALSE, : agora could not be fit on page. It will not be plotted.
## Warning in wordcloud::wordcloud(corpus, min.freq = 1, max.words = 60,
## random.order = FALSE, : essenciais could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(corpus, min.freq = 1, max.words = 60,
## random.order = FALSE, : tarefas could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(corpus, min.freq = 1, max.words = 60,
## random.order = FALSE, : dados could not be fit on page. It will not be plotted.
## Warning in wordcloud::wordcloud(corpus, min.freq = 1, max.words = 60,
## random.order = FALSE, : perguntei could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(corpus, min.freq = 1, max.words = 60,
## random.order = FALSE, : phdli could not be fit on page. It will not be plotted.
## Warning in wordcloud::wordcloud(corpus, min.freq = 1, max.words = 60,
## random.order = FALSE, : sessenta could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(corpus, min.freq = 1, max.words = 60,
## random.order = FALSE, : prévio could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(corpus, min.freq = 1, max.words = 60,
## random.order = FALSE, : notícias could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(corpus, min.freq = 1, max.words = 60,
## random.order = FALSE, : escrever could not be fit on page. It will not be
## plotted.
## Warning in wordcloud::wordcloud(corpus, min.freq = 1, max.words = 60,
## random.order = FALSE, : usando could not be fit on page. It will not be
## plotted.

Teorema

Parte 1:

flu <- read.csv("flu.csv")
QTD_Media <- 200
Tamanho <- 35

hist(flu$age, xlab="Frequencias das Idades das Mortes", ylab="Densidade",probability=T,main="Histograma/Curva Densidade do Conjunto de Dados flu",ylim=c(0,0.029),col="pink")
lines(density(flu$age),col="blue")

Parte 2:

Medias <- rep(NA, Tamanho)
for (i in 1:QTD_Media) {
  Amostra <- sample(flu$age, size=Tamanho)
  Medias[i] <- mean(Amostra)
}

Parte 03

hist(Medias, probability = T, main="Histograma/Curva Densidade das Medias Amostrais",xlab="Media das Amostras", ylab="Densidade",ylim=c(0,0.11),xlim=c(24,60),col="grey")
lines(density(Medias), col="red")