library(readxl)
library(flextable)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
DMQ <- read.csv2("C:/Users/louiz/Downloads/Base_de_dados-master/Escola_Oliveira_p_Livro_DMQ.csv")
head(DMQ) %>% data.frame() %>% flextable() %>% theme_box()
id | grau_pagamento | sexo | raca | casado | idade | anos_trabalho | desempenho | salario |
1 | 1 | 1 | 1 | 0 | 0.5 | 2 | 890 | |
2 | 1 | 1 | 0 | 0 | 25 | 2.4 | 3 | 1,100 |
3 | 2 | 1 | 0 | 0 | 23 | 3.6 | 7 | 1,070 |
4 | 1 | 0 | 1 | 0 | 26 | 1.9 | 3 | 1,190 |
5 | 2 | 1 | 0 | 1 | 22 | 3.4 | 6 | 1,290 |
6 | 1 | 1 | 1 | 1 | 23 | 2.8 | 4 | 1,010 |
str(DMQ)
## 'data.frame': 420 obs. of 9 variables:
## $ id : int 1 2 3 4 5 6 7 8 9 10 ...
## $ grau_pagamento: int 1 1 2 1 2 1 1 1 2 1 ...
## $ sexo : int 1 1 1 0 1 1 0 1 0 1 ...
## $ raca : int 1 0 0 1 0 1 0 0 0 1 ...
## $ casado : int 0 0 0 0 1 1 1 1 0 1 ...
## $ idade : int NA 25 23 26 22 23 31 21 31 38 ...
## $ anos_trabalho : num 0.5 2.4 3.6 1.9 3.4 2.8 2.3 0.4 3 1.4 ...
## $ desempenho : int 2 3 7 3 6 4 3 2 5 3 ...
## $ salario : int 890 1100 1070 1190 1290 1010 990 880 1520 1290 ...
plot(DMQ$desempenho,DMQ$salario,pch=20,
main="Diagrama de dispersao")
abline(lsfit(DMQ$desempenho,DMQ$salario),col="orange")
cor(DMQ$desempenho,DMQ$salario)
## [1] 0.8346379
DMQ2 = na.omit(DMQ)
library(corrplot)
## Warning: package 'corrplot' was built under R version 4.2.2
## corrplot 0.92 loaded
selecao = c("grau_pagamento","anos_trabalho","desempenho","salario")
DMQ2 %>% select(selecao) %>% cor() %>% corrplot(method="number")
## Warning: Using an external vector in selections was deprecated in tidyselect 1.1.0.
## ℹ Please use `all_of()` or `any_of()` instead.
## # Was:
## data %>% select(selecao)
##
## # Now:
## data %>% select(all_of(selecao))
##
## See <https://tidyselect.r-lib.org/reference/faq-external-vector.html>.