Para listar o diretório de trabalho atual basta digitar no console:
getwd()
Caso seja necessário mudar o diretório de trabalho para outra pasta de sua preferência, use:
Arquivo Dados_soja.csv:
dados_soja = read.csv("Dados_soja.csv", header = T, sep= " ")
soja = read.table("https://raw.githubusercontent.com/leocbc/CursoR_iniciante/master/Arquivos/Modulo_2/soja.txt", header = T)
feijao = read.table("https://raw.githubusercontent.com/leocbc/CursoR_iniciante/master/Arquivos/Modulo_2/feijao.txt", header = T)
head(feijao)
## REP TRAT NDIF TP VC ACAM ST P5V COMPV NGV PG5V PROD
## 1 1 21 45 2 3 4 52 23.3 108.0 67 15.2 442.7
## 2 2 21 46 1 4 2 47 18.4 97.0 85 13.8 183.7
## 3 3 21 41 1 3 2 57 24.6 102.0 70 15.7 540.1
## 4 4 21 45 2 4 2 66 11.0 78.0 50 9.4 513.8
## 5 1 22 46 2 3 2 35 22.3 99.2 68 16.4 253.7
## 6 2 22 45 2 3 4 52 17.5 81.0 62 13.0 97.9
str(feijao)
## 'data.frame': 80 obs. of 12 variables:
## $ REP : int 1 2 3 4 1 2 3 4 1 2 ...
## $ TRAT : int 21 21 21 21 22 22 22 22 23 23 ...
## $ NDIF : int 45 46 41 45 46 45 45 45 45 46 ...
## $ TP : int 2 1 1 2 2 2 2 3 1 1 ...
## $ VC : int 3 4 3 4 3 3 3 2 4 4 ...
## $ ACAM : int 4 2 2 2 2 4 4 3 2 2 ...
## $ ST : int 52 47 57 66 35 52 52 54 54 49 ...
## $ P5V : num 23.3 18.4 24.6 11 22.3 17.5 23.3 19.8 20.2 20.8 ...
## $ COMPV: num 108 97 102 78 99.2 81 108 106 98.9 99 ...
## $ NGV : int 67 85 70 50 68 62 67 62 78 66 ...
## $ PG5V : num 15.2 13.8 15.7 9.4 16.4 13 15.2 15 15.5 15.4 ...
## $ PROD : num 443 184 540 514 254 ...
summary(feijao)
## REP TRAT NDIF TP VC
## Min. :1.00 Min. :21.00 Min. :37.00 Min. :1.000 Min. :2.000
## 1st Qu.:1.75 1st Qu.:25.75 1st Qu.:40.00 1st Qu.:1.000 1st Qu.:3.000
## Median :2.50 Median :30.50 Median :40.00 Median :1.000 Median :3.000
## Mean :2.50 Mean :30.50 Mean :41.08 Mean :1.562 Mean :3.025
## 3rd Qu.:3.25 3rd Qu.:35.25 3rd Qu.:42.25 3rd Qu.:2.000 3rd Qu.:3.000
## Max. :4.00 Max. :40.00 Max. :47.00 Max. :3.000 Max. :4.000
## ACAM ST P5V COMPV
## Min. :1.000 Min. :20.00 Min. :11.00 Min. : 1.00
## 1st Qu.:2.000 1st Qu.:37.25 1st Qu.:15.62 1st Qu.: 88.00
## Median :3.000 Median :48.50 Median :16.90 Median : 96.00
## Mean :2.812 Mean :46.67 Mean :17.36 Mean : 92.14
## 3rd Qu.:3.000 3rd Qu.:57.00 3rd Qu.:19.02 3rd Qu.:100.00
## Max. :5.000 Max. :76.00 Max. :24.60 Max. :112.00
## NGV PG5V PROD
## Min. :41.00 Min. : 8.90 Min. : 89.9
## 1st Qu.:58.00 1st Qu.: 12.07 1st Qu.: 374.7
## Median :63.50 Median : 13.20 Median : 473.5
## Mean :63.25 Mean : 15.85 Mean : 489.1
## 3rd Qu.:68.00 3rd Qu.: 14.70 3rd Qu.: 616.8
## Max. :85.00 Max. :131.00 Max. :1016.2
filter(feijao, PROD > 489.1 & TRAT ==21)
## REP TRAT NDIF TP VC ACAM ST P5V COMPV NGV PG5V PROD
## 1 3 21 41 1 3 2 57 24.6 102 70 15.7 540.1
## 2 4 21 45 2 4 2 66 11.0 78 50 9.4 513.8
select(feijao, starts_with("P"))
## P5V PG5V PROD
## 1 23.3 15.2 442.7
## 2 18.4 13.8 183.7
## 3 24.6 15.7 540.1
## 4 11.0 9.4 513.8
## 5 22.3 16.4 253.7
## 6 17.5 13.0 97.9
## 7 23.3 15.2 442.7
## 8 19.8 15.0 165.3
## 9 20.2 15.5 528.6
## 10 20.8 15.4 90.3
## 11 22.7 14.7 240.7
## 12 19.0 13.7 376.6
## 13 22.5 13.7 270.1
## 14 16.9 13.3 400.4
## 15 16.9 13.7 439.8
## 16 20.3 16.6 209.2
## 17 16.9 12.6 259.6
## 18 19.0 14.0 364.1
## 19 17.6 12.9 408.0
## 20 16.2 12.1 521.4
## 21 19.7 14.0 89.9
## 22 16.0 11.0 422.0
## 23 16.9 12.4 550.7
## 24 16.3 11.8 454.9
## 25 14.2 9.3 510.5
## 26 15.2 12.1 716.3
## 27 19.7 16.4 1016.2
## 28 18.8 13.0 529.8
## 29 21.2 15.9 412.1
## 30 14.0 11.5 723.9
## 31 15.8 12.6 605.8
## 32 16.1 12.4 560.7
## 33 17.6 13.0 586.7
## 34 15.4 11.6 657.1
## 35 16.4 12.8 330.5
## 36 16.4 11.5 463.0
## 37 18.3 13.1 268.1
## 38 19.1 13.9 561.4
## 39 19.6 15.4 672.6
## 40 15.9 14.4 606.2
## 41 14.4 11.8 562.1
## 42 11.4 8.9 785.9
## 43 14.1 11.3 663.9
## 44 16.4 15.2 785.0
## 45 15.9 12.1 470.0
## 46 22.0 16.7 369.1
## 47 16.4 13.2 656.3
## 48 16.9 13.7 688.2
## 49 13.6 11.2 622.6
## 50 16.6 13.6 392.0
## 51 16.2 13.4 728.4
## 52 17.7 13.0 389.1
## 53 14.9 11.2 378.5
## 54 14.6 11.2 614.8
## 55 19.0 15.2 951.4
## 56 15.0 12.9 917.0
## 57 17.1 13.2 363.4
## 58 14.9 11.0 579.7
## 59 15.9 12.5 707.2
## 60 20.4 16.1 550.2
## 61 18.3 14.2 443.1
## 62 16.9 13.3 400.4
## 63 15.7 11.7 392.2
## 64 17.3 13.2 223.9
## 65 20.0 14.7 269.1
## 66 19.9 15.0 477.0
## 67 20.2 15.2 579.1
## 68 17.8 13.8 486.6
## 69 13.9 10.0 231.3
## 70 12.8 10.2 724.0
## 71 14.8 10.4 434.1
## 72 15.1 12.4 380.8
## 73 14.5 12.0 437.7
## 74 14.0 11.3 261.3
## 75 17.1 12.2 168.3
## 76 14.8 12.3 541.9
## 77 18.0 14.1 879.0
## 78 18.3 14.6 700.0
## 79 16.4 109.0 789.6
## 80 18.0 131.0 646.4
arrange(feijao, desc(PROD))
## REP TRAT NDIF TP VC ACAM ST P5V COMPV NGV PG5V PROD
## 1 3 27 40 2 3 3 56 19.7 109.00 72 16.4 1016.2
## 2 3 34 38 1 4 2 55 19.0 103.00 74 15.2 951.4
## 3 4 34 40 1 3 2 41 15.0 88.00 61 12.9 917.0
## 4 1 40 41 1 3 2 47 18.0 98.00 69 14.1 879.0
## 5 3 40 38 1 3 4 33 16.4 1.00 55 109.0 789.6
## 6 2 31 40 1 3 2 56 11.4 75.00 56 8.9 785.9
## 7 4 31 40 1 3 4 69 16.4 100.00 64 15.2 785.0
## 8 3 33 40 1 3 2 69 16.2 94.00 69 13.4 728.4
## 9 2 38 40 2 3 4 50 12.8 72.00 52 10.2 724.0
## 10 2 28 40 2 3 3 32 14.0 92.00 67 11.5 723.9
## 11 2 27 40 1 4 2 28 15.2 97.00 68 12.1 716.3
## 12 3 35 40 1 3 3 48 15.9 99.00 72 12.5 707.2
## 13 2 40 40 1 3 3 47 18.3 99.00 68 14.6 700.0
## 14 4 32 40 1 3 4 69 16.9 103.00 68 13.7 688.2
## 15 3 30 40 2 3 3 50 19.6 111.00 68 15.4 672.6
## 16 3 31 40 1 3 2 52 14.1 89.00 63 11.3 663.9
## 17 2 29 40 1 2 3 49 15.4 95.00 61 11.6 657.1
## 18 3 32 40 1 3 3 43 16.4 94.00 55 13.2 656.3
## 19 4 40 40 1 3 3 51 18.0 1.01 56 131.0 646.4
## 20 1 33 41 1 4 1 46 13.6 82.00 59 11.2 622.6
## 21 2 34 40 1 3 2 52 14.6 96.00 56 11.2 614.8
## 22 4 30 40 3 2 4 60 15.9 92.00 60 14.4 606.2
## 23 3 28 40 1 3 3 26 15.8 96.00 63 12.6 605.8
## 24 1 29 40 2 3 3 45 17.6 96.00 64 13.0 586.7
## 25 2 35 40 2 3 3 43 14.9 99.00 65 11.0 579.7
## 26 3 37 40 3 3 5 31 20.2 111.00 67 15.2 579.1
## 27 1 31 41 1 4 1 25 14.4 86.00 63 11.8 562.1
## 28 2 30 38 3 3 4 43 19.1 101.00 69 13.9 561.4
## 29 4 28 40 2 3 3 61 16.1 102.00 56 12.4 560.7
## 30 3 26 40 2 3 3 54 16.9 103.00 63 12.4 550.7
## 31 4 35 40 1 3 2 57 20.4 103.00 80 16.1 550.2
## 32 4 39 40 1 3 2 43 14.8 69.00 48 12.3 541.9
## 33 3 21 41 1 3 2 57 24.6 102.00 70 15.7 540.1
## 34 4 27 40 1 3 4 68 18.8 96.00 54 13.0 529.8
## 35 1 23 45 1 4 2 54 20.2 98.90 78 15.5 528.6
## 36 4 25 40 1 4 2 60 16.2 91.00 75 12.1 521.4
## 37 4 21 45 2 4 2 66 11.0 78.00 50 9.4 513.8
## 38 1 27 40 3 3 4 38 14.2 88.00 58 9.3 510.5
## 39 4 37 42 3 3 3 56 17.8 99.00 57 13.8 486.6
## 40 2 37 38 3 2 4 20 19.9 106.00 64 15.0 477.0
## 41 1 32 40 1 2 3 20 15.9 91.00 62 12.1 470.0
## 42 4 29 40 2 2 4 62 16.4 94.00 58 11.5 463.0
## 43 4 26 40 2 3 3 50 16.3 98.00 58 11.8 454.9
## 44 1 36 37 1 3 2 22 18.3 100.00 66 14.2 443.1
## 45 1 21 45 2 3 4 52 23.3 108.00 67 15.2 442.7
## 46 3 22 45 2 3 4 52 23.3 108.00 67 15.2 442.7
## 47 3 24 45 1 3 2 65 16.9 90.00 62 13.7 439.8
## 48 1 39 40 1 3 2 30 14.5 79.00 53 12.0 437.7
## 49 3 38 40 1 4 2 76 14.8 89.00 50 10.4 434.1
## 50 2 26 40 2 3 3 38 16.0 98.00 52 11.0 422.0
## 51 1 28 37 1 3 2 28 21.2 103.00 71 15.9 412.1
## 52 3 25 40 1 4 2 62 17.6 93.00 67 12.9 408.0
## 53 2 24 43 1 3 4 57 16.9 92.00 67 13.3 400.4
## 54 2 36 38 1 4 3 57 16.9 92.00 67 13.3 400.4
## 55 3 36 40 1 2 3 44 15.7 96.00 50 11.7 392.2
## 56 2 33 40 1 3 2 21 16.6 96.00 70 13.6 392.0
## 57 4 33 43 1 4 2 57 17.7 81.00 62 13.0 389.1
## 58 4 38 42 1 3 2 65 15.1 81.00 59 12.4 380.8
## 59 1 34 40 1 2 2 26 14.9 89.00 59 11.2 378.5
## 60 4 23 47 1 3 3 57 19.0 86.00 57 13.7 376.6
## 61 2 32 38 1 3 3 34 22.0 112.00 74 16.7 369.1
## 62 2 25 38 1 4 2 39 19.0 86.00 68 14.0 364.1
## 63 1 35 41 1 3 2 42 17.1 100.00 72 13.2 363.4
## 64 3 29 40 3 2 4 32 16.4 92.00 58 12.8 330.5
## 65 1 24 46 3 4 4 43 22.5 92.00 71 13.7 270.1
## 66 1 37 44 2 2 3 30 20.0 106.00 66 14.7 269.1
## 67 1 30 40 3 2 4 27 18.3 98.00 71 13.1 268.1
## 68 2 39 38 1 2 2 27 14.0 80.00 41 11.3 261.3
## 69 1 25 43 3 3 3 47 16.9 84.00 66 12.6 259.6
## 70 1 22 46 2 3 2 35 22.3 99.20 68 16.4 253.7
## 71 3 23 45 2 3 3 49 22.7 99.00 63 14.7 240.7
## 72 1 38 45 2 3 3 40 13.9 83.00 52 10.0 231.3
## 73 4 36 40 2 2 4 60 17.3 97.00 61 13.2 223.9
## 74 4 24 46 2 3 3 67 20.3 85.00 69 16.6 209.2
## 75 2 21 46 1 4 2 47 18.4 97.00 85 13.8 183.7
## 76 3 39 40 1 3 2 39 17.1 88.00 50 12.2 168.3
## 77 4 22 45 3 2 3 54 19.8 106.00 62 15.0 165.3
## 78 2 22 45 2 3 4 52 17.5 81.00 62 13.0 97.9
## 79 2 23 46 1 4 2 49 20.8 99.00 66 15.4 90.3
## 80 1 26 44 3 3 3 30 19.7 108.00 74 14.0 89.9
feijao %>% arrange(desc(PROD)) %>% select(TRAT)
## TRAT
## 1 27
## 2 34
## 3 34
## 4 40
## 5 40
## 6 31
## 7 31
## 8 33
## 9 38
## 10 28
## 11 27
## 12 35
## 13 40
## 14 32
## 15 30
## 16 31
## 17 29
## 18 32
## 19 40
## 20 33
## 21 34
## 22 30
## 23 28
## 24 29
## 25 35
## 26 37
## 27 31
## 28 30
## 29 28
## 30 26
## 31 35
## 32 39
## 33 21
## 34 27
## 35 23
## 36 25
## 37 21
## 38 27
## 39 37
## 40 37
## 41 32
## 42 29
## 43 26
## 44 36
## 45 21
## 46 22
## 47 24
## 48 39
## 49 38
## 50 26
## 51 28
## 52 25
## 53 24
## 54 36
## 55 36
## 56 33
## 57 33
## 58 38
## 59 34
## 60 23
## 61 32
## 62 25
## 63 35
## 64 29
## 65 24
## 66 37
## 67 30
## 68 39
## 69 25
## 70 22
## 71 23
## 72 38
## 73 36
## 74 24
## 75 21
## 76 39
## 77 22
## 78 22
## 79 23
## 80 26
feijao %>% arrange(desc(PROD)) %>% select(TRAT)
## TRAT
## 1 27
## 2 34
## 3 34
## 4 40
## 5 40
## 6 31
## 7 31
## 8 33
## 9 38
## 10 28
## 11 27
## 12 35
## 13 40
## 14 32
## 15 30
## 16 31
## 17 29
## 18 32
## 19 40
## 20 33
## 21 34
## 22 30
## 23 28
## 24 29
## 25 35
## 26 37
## 27 31
## 28 30
## 29 28
## 30 26
## 31 35
## 32 39
## 33 21
## 34 27
## 35 23
## 36 25
## 37 21
## 38 27
## 39 37
## 40 37
## 41 32
## 42 29
## 43 26
## 44 36
## 45 21
## 46 22
## 47 24
## 48 39
## 49 38
## 50 26
## 51 28
## 52 25
## 53 24
## 54 36
## 55 36
## 56 33
## 57 33
## 58 38
## 59 34
## 60 23
## 61 32
## 62 25
## 63 35
## 64 29
## 65 24
## 66 37
## 67 30
## 68 39
## 69 25
## 70 22
## 71 23
## 72 38
## 73 36
## 74 24
## 75 21
## 76 39
## 77 22
## 78 22
## 79 23
## 80 26
mutate(feijao, PROD = log(PROD))
## REP TRAT NDIF TP VC ACAM ST P5V COMPV NGV PG5V PROD
## 1 1 21 45 2 3 4 52 23.3 108.00 67 15.2 6.092892
## 2 2 21 46 1 4 2 47 18.4 97.00 85 13.8 5.213304
## 3 3 21 41 1 3 2 57 24.6 102.00 70 15.7 6.291754
## 4 4 21 45 2 4 2 66 11.0 78.00 50 9.4 6.241834
## 5 1 22 46 2 3 2 35 22.3 99.20 68 16.4 5.536152
## 6 2 22 45 2 3 4 52 17.5 81.00 62 13.0 4.583947
## 7 3 22 45 2 3 4 52 23.3 108.00 67 15.2 6.092892
## 8 4 22 45 3 2 3 54 19.8 106.00 62 15.0 5.107762
## 9 1 23 45 1 4 2 54 20.2 98.90 78 15.5 6.270232
## 10 2 23 46 1 4 2 49 20.8 99.00 66 15.4 4.503137
## 11 3 23 45 2 3 3 49 22.7 99.00 63 14.7 5.483551
## 12 4 23 47 1 3 3 57 19.0 86.00 57 13.7 5.931184
## 13 1 24 46 3 4 4 43 22.5 92.00 71 13.7 5.598792
## 14 2 24 43 1 3 4 57 16.9 92.00 67 13.3 5.992464
## 15 3 24 45 1 3 2 65 16.9 90.00 62 13.7 6.086320
## 16 4 24 46 2 3 3 67 20.3 85.00 69 16.6 5.343291
## 17 1 25 43 3 3 3 47 16.9 84.00 66 12.6 5.559142
## 18 2 25 38 1 4 2 39 19.0 86.00 68 14.0 5.897429
## 19 3 25 40 1 4 2 62 17.6 93.00 67 12.9 6.011267
## 20 4 25 40 1 4 2 60 16.2 91.00 75 12.1 6.256518
## 21 1 26 44 3 3 3 30 19.7 108.00 74 14.0 4.498698
## 22 2 26 40 2 3 3 38 16.0 98.00 52 11.0 6.045005
## 23 3 26 40 2 3 3 54 16.9 103.00 63 12.4 6.311190
## 24 4 26 40 2 3 3 50 16.3 98.00 58 11.8 6.120078
## 25 1 27 40 3 3 4 38 14.2 88.00 58 9.3 6.235391
## 26 2 27 40 1 4 2 28 15.2 97.00 68 12.1 6.574099
## 27 3 27 40 2 3 3 56 19.7 109.00 72 16.4 6.923825
## 28 4 27 40 1 3 4 68 18.8 96.00 54 13.0 6.272500
## 29 1 28 37 1 3 2 28 21.2 103.00 71 15.9 6.021266
## 30 2 28 40 2 3 3 32 14.0 92.00 67 11.5 6.584653
## 31 3 28 40 1 3 3 26 15.8 96.00 63 12.6 6.406550
## 32 4 28 40 2 3 3 61 16.1 102.00 56 12.4 6.329186
## 33 1 29 40 2 3 3 45 17.6 96.00 64 13.0 6.374514
## 34 2 29 40 1 2 3 49 15.4 95.00 61 11.6 6.487836
## 35 3 29 40 3 2 4 32 16.4 92.00 58 12.8 5.800607
## 36 4 29 40 2 2 4 62 16.4 94.00 58 11.5 6.137727
## 37 1 30 40 3 2 4 27 18.3 98.00 71 13.1 5.591360
## 38 2 30 38 3 3 4 43 19.1 101.00 69 13.9 6.330434
## 39 3 30 40 2 3 3 50 19.6 111.00 68 15.4 6.511151
## 40 4 30 40 3 2 4 60 15.9 92.00 60 14.4 6.407210
## 41 1 31 41 1 4 1 25 14.4 86.00 63 11.8 6.331680
## 42 2 31 40 1 3 2 56 11.4 75.00 56 8.9 6.666830
## 43 3 31 40 1 3 2 52 14.1 89.00 63 11.3 6.498132
## 44 4 31 40 1 3 4 69 16.4 100.00 64 15.2 6.665684
## 45 1 32 40 1 2 3 20 15.9 91.00 62 12.1 6.152733
## 46 2 32 38 1 3 3 34 22.0 112.00 74 16.7 5.911068
## 47 3 32 40 1 3 3 43 16.4 94.00 55 13.2 6.486618
## 48 4 32 40 1 3 4 69 16.9 103.00 68 13.7 6.534079
## 49 1 33 41 1 4 1 46 13.6 82.00 59 11.2 6.433904
## 50 2 33 40 1 3 2 21 16.6 96.00 70 13.6 5.971262
## 51 3 33 40 1 3 2 69 16.2 94.00 69 13.4 6.590850
## 52 4 33 43 1 4 2 57 17.7 81.00 62 13.0 5.963836
## 53 1 34 40 1 2 2 26 14.9 89.00 59 11.2 5.936216
## 54 2 34 40 1 3 2 52 14.6 96.00 56 11.2 6.421297
## 55 3 34 38 1 4 2 55 19.0 103.00 74 15.2 6.857935
## 56 4 34 40 1 3 2 41 15.0 88.00 61 12.9 6.821107
## 57 1 35 41 1 3 2 42 17.1 100.00 72 13.2 5.895504
## 58 2 35 40 2 3 3 43 14.9 99.00 65 11.0 6.362511
## 59 3 35 40 1 3 3 48 15.9 99.00 72 12.5 6.561314
## 60 4 35 40 1 3 2 57 20.4 103.00 80 16.1 6.310282
## 61 1 36 37 1 3 2 22 18.3 100.00 66 14.2 6.093795
## 62 2 36 38 1 4 3 57 16.9 92.00 67 13.3 5.992464
## 63 3 36 40 1 2 3 44 15.7 96.00 50 11.7 5.971772
## 64 4 36 40 2 2 4 60 17.3 97.00 61 13.2 5.411200
## 65 1 37 44 2 2 3 30 20.0 106.00 66 14.7 5.595083
## 66 2 37 38 3 2 4 20 19.9 106.00 64 15.0 6.167516
## 67 3 37 40 3 3 5 31 20.2 111.00 67 15.2 6.361475
## 68 4 37 42 3 3 3 56 17.8 99.00 57 13.8 6.187442
## 69 1 38 45 2 3 3 40 13.9 83.00 52 10.0 5.443716
## 70 2 38 40 2 3 4 50 12.8 72.00 52 10.2 6.584791
## 71 3 38 40 1 4 2 76 14.8 89.00 50 10.4 6.073275
## 72 4 38 42 1 3 2 65 15.1 81.00 59 12.4 5.942274
## 73 1 39 40 1 3 2 30 14.5 79.00 53 12.0 6.081534
## 74 2 39 38 1 2 2 27 14.0 80.00 41 11.3 5.565669
## 75 3 39 40 1 3 2 39 17.1 88.00 50 12.2 5.125748
## 76 4 39 40 1 3 2 43 14.8 69.00 48 12.3 6.295081
## 77 1 40 41 1 3 2 47 18.0 98.00 69 14.1 6.778785
## 78 2 40 40 1 3 3 47 18.3 99.00 68 14.6 6.551080
## 79 3 40 38 1 3 4 33 16.4 1.00 55 109.0 6.671526
## 80 4 40 40 1 3 3 51 18.0 1.01 56 131.0 6.471419
feijao %>%
mutate(
classe = ifelse(PROD > 489.1, "Produtiva", "Não Produtiva")
) %>%
select(TRAT, classe)
## TRAT classe
## 1 21 Não Produtiva
## 2 21 Não Produtiva
## 3 21 Produtiva
## 4 21 Produtiva
## 5 22 Não Produtiva
## 6 22 Não Produtiva
## 7 22 Não Produtiva
## 8 22 Não Produtiva
## 9 23 Produtiva
## 10 23 Não Produtiva
## 11 23 Não Produtiva
## 12 23 Não Produtiva
## 13 24 Não Produtiva
## 14 24 Não Produtiva
## 15 24 Não Produtiva
## 16 24 Não Produtiva
## 17 25 Não Produtiva
## 18 25 Não Produtiva
## 19 25 Não Produtiva
## 20 25 Produtiva
## 21 26 Não Produtiva
## 22 26 Não Produtiva
## 23 26 Produtiva
## 24 26 Não Produtiva
## 25 27 Produtiva
## 26 27 Produtiva
## 27 27 Produtiva
## 28 27 Produtiva
## 29 28 Não Produtiva
## 30 28 Produtiva
## 31 28 Produtiva
## 32 28 Produtiva
## 33 29 Produtiva
## 34 29 Produtiva
## 35 29 Não Produtiva
## 36 29 Não Produtiva
## 37 30 Não Produtiva
## 38 30 Produtiva
## 39 30 Produtiva
## 40 30 Produtiva
## 41 31 Produtiva
## 42 31 Produtiva
## 43 31 Produtiva
## 44 31 Produtiva
## 45 32 Não Produtiva
## 46 32 Não Produtiva
## 47 32 Produtiva
## 48 32 Produtiva
## 49 33 Produtiva
## 50 33 Não Produtiva
## 51 33 Produtiva
## 52 33 Não Produtiva
## 53 34 Não Produtiva
## 54 34 Produtiva
## 55 34 Produtiva
## 56 34 Produtiva
## 57 35 Não Produtiva
## 58 35 Produtiva
## 59 35 Produtiva
## 60 35 Produtiva
## 61 36 Não Produtiva
## 62 36 Não Produtiva
## 63 36 Não Produtiva
## 64 36 Não Produtiva
## 65 37 Não Produtiva
## 66 37 Não Produtiva
## 67 37 Produtiva
## 68 37 Não Produtiva
## 69 38 Não Produtiva
## 70 38 Produtiva
## 71 38 Não Produtiva
## 72 38 Não Produtiva
## 73 39 Não Produtiva
## 74 39 Não Produtiva
## 75 39 Não Produtiva
## 76 39 Produtiva
## 77 40 Produtiva
## 78 40 Produtiva
## 79 40 Produtiva
## 80 40 Produtiva
library(tidyr)
feijao_2 = feijao %>% unite(col = trat_rep,
TRAT,REP,
sep = "_")
feijao_2
## trat_rep NDIF TP VC ACAM ST P5V COMPV NGV PG5V PROD
## 1 21_1 45 2 3 4 52 23.3 108.00 67 15.2 442.7
## 2 21_2 46 1 4 2 47 18.4 97.00 85 13.8 183.7
## 3 21_3 41 1 3 2 57 24.6 102.00 70 15.7 540.1
## 4 21_4 45 2 4 2 66 11.0 78.00 50 9.4 513.8
## 5 22_1 46 2 3 2 35 22.3 99.20 68 16.4 253.7
## 6 22_2 45 2 3 4 52 17.5 81.00 62 13.0 97.9
## 7 22_3 45 2 3 4 52 23.3 108.00 67 15.2 442.7
## 8 22_4 45 3 2 3 54 19.8 106.00 62 15.0 165.3
## 9 23_1 45 1 4 2 54 20.2 98.90 78 15.5 528.6
## 10 23_2 46 1 4 2 49 20.8 99.00 66 15.4 90.3
## 11 23_3 45 2 3 3 49 22.7 99.00 63 14.7 240.7
## 12 23_4 47 1 3 3 57 19.0 86.00 57 13.7 376.6
## 13 24_1 46 3 4 4 43 22.5 92.00 71 13.7 270.1
## 14 24_2 43 1 3 4 57 16.9 92.00 67 13.3 400.4
## 15 24_3 45 1 3 2 65 16.9 90.00 62 13.7 439.8
## 16 24_4 46 2 3 3 67 20.3 85.00 69 16.6 209.2
## 17 25_1 43 3 3 3 47 16.9 84.00 66 12.6 259.6
## 18 25_2 38 1 4 2 39 19.0 86.00 68 14.0 364.1
## 19 25_3 40 1 4 2 62 17.6 93.00 67 12.9 408.0
## 20 25_4 40 1 4 2 60 16.2 91.00 75 12.1 521.4
## 21 26_1 44 3 3 3 30 19.7 108.00 74 14.0 89.9
## 22 26_2 40 2 3 3 38 16.0 98.00 52 11.0 422.0
## 23 26_3 40 2 3 3 54 16.9 103.00 63 12.4 550.7
## 24 26_4 40 2 3 3 50 16.3 98.00 58 11.8 454.9
## 25 27_1 40 3 3 4 38 14.2 88.00 58 9.3 510.5
## 26 27_2 40 1 4 2 28 15.2 97.00 68 12.1 716.3
## 27 27_3 40 2 3 3 56 19.7 109.00 72 16.4 1016.2
## 28 27_4 40 1 3 4 68 18.8 96.00 54 13.0 529.8
## 29 28_1 37 1 3 2 28 21.2 103.00 71 15.9 412.1
## 30 28_2 40 2 3 3 32 14.0 92.00 67 11.5 723.9
## 31 28_3 40 1 3 3 26 15.8 96.00 63 12.6 605.8
## 32 28_4 40 2 3 3 61 16.1 102.00 56 12.4 560.7
## 33 29_1 40 2 3 3 45 17.6 96.00 64 13.0 586.7
## 34 29_2 40 1 2 3 49 15.4 95.00 61 11.6 657.1
## 35 29_3 40 3 2 4 32 16.4 92.00 58 12.8 330.5
## 36 29_4 40 2 2 4 62 16.4 94.00 58 11.5 463.0
## 37 30_1 40 3 2 4 27 18.3 98.00 71 13.1 268.1
## 38 30_2 38 3 3 4 43 19.1 101.00 69 13.9 561.4
## 39 30_3 40 2 3 3 50 19.6 111.00 68 15.4 672.6
## 40 30_4 40 3 2 4 60 15.9 92.00 60 14.4 606.2
## 41 31_1 41 1 4 1 25 14.4 86.00 63 11.8 562.1
## 42 31_2 40 1 3 2 56 11.4 75.00 56 8.9 785.9
## 43 31_3 40 1 3 2 52 14.1 89.00 63 11.3 663.9
## 44 31_4 40 1 3 4 69 16.4 100.00 64 15.2 785.0
## 45 32_1 40 1 2 3 20 15.9 91.00 62 12.1 470.0
## 46 32_2 38 1 3 3 34 22.0 112.00 74 16.7 369.1
## 47 32_3 40 1 3 3 43 16.4 94.00 55 13.2 656.3
## 48 32_4 40 1 3 4 69 16.9 103.00 68 13.7 688.2
## 49 33_1 41 1 4 1 46 13.6 82.00 59 11.2 622.6
## 50 33_2 40 1 3 2 21 16.6 96.00 70 13.6 392.0
## 51 33_3 40 1 3 2 69 16.2 94.00 69 13.4 728.4
## 52 33_4 43 1 4 2 57 17.7 81.00 62 13.0 389.1
## 53 34_1 40 1 2 2 26 14.9 89.00 59 11.2 378.5
## 54 34_2 40 1 3 2 52 14.6 96.00 56 11.2 614.8
## 55 34_3 38 1 4 2 55 19.0 103.00 74 15.2 951.4
## 56 34_4 40 1 3 2 41 15.0 88.00 61 12.9 917.0
## 57 35_1 41 1 3 2 42 17.1 100.00 72 13.2 363.4
## 58 35_2 40 2 3 3 43 14.9 99.00 65 11.0 579.7
## 59 35_3 40 1 3 3 48 15.9 99.00 72 12.5 707.2
## 60 35_4 40 1 3 2 57 20.4 103.00 80 16.1 550.2
## 61 36_1 37 1 3 2 22 18.3 100.00 66 14.2 443.1
## 62 36_2 38 1 4 3 57 16.9 92.00 67 13.3 400.4
## 63 36_3 40 1 2 3 44 15.7 96.00 50 11.7 392.2
## 64 36_4 40 2 2 4 60 17.3 97.00 61 13.2 223.9
## 65 37_1 44 2 2 3 30 20.0 106.00 66 14.7 269.1
## 66 37_2 38 3 2 4 20 19.9 106.00 64 15.0 477.0
## 67 37_3 40 3 3 5 31 20.2 111.00 67 15.2 579.1
## 68 37_4 42 3 3 3 56 17.8 99.00 57 13.8 486.6
## 69 38_1 45 2 3 3 40 13.9 83.00 52 10.0 231.3
## 70 38_2 40 2 3 4 50 12.8 72.00 52 10.2 724.0
## 71 38_3 40 1 4 2 76 14.8 89.00 50 10.4 434.1
## 72 38_4 42 1 3 2 65 15.1 81.00 59 12.4 380.8
## 73 39_1 40 1 3 2 30 14.5 79.00 53 12.0 437.7
## 74 39_2 38 1 2 2 27 14.0 80.00 41 11.3 261.3
## 75 39_3 40 1 3 2 39 17.1 88.00 50 12.2 168.3
## 76 39_4 40 1 3 2 43 14.8 69.00 48 12.3 541.9
## 77 40_1 41 1 3 2 47 18.0 98.00 69 14.1 879.0
## 78 40_2 40 1 3 3 47 18.3 99.00 68 14.6 700.0
## 79 40_3 38 1 3 4 33 16.4 1.00 55 109.0 789.6
## 80 40_4 40 1 3 3 51 18.0 1.01 56 131.0 646.4
feijao_2 %>% separate(col = trat_rep,
into = c("TRAT","REP"),
sep = "_",
extra = "drop")
## TRAT REP NDIF TP VC ACAM ST P5V COMPV NGV PG5V PROD
## 1 21 1 45 2 3 4 52 23.3 108.00 67 15.2 442.7
## 2 21 2 46 1 4 2 47 18.4 97.00 85 13.8 183.7
## 3 21 3 41 1 3 2 57 24.6 102.00 70 15.7 540.1
## 4 21 4 45 2 4 2 66 11.0 78.00 50 9.4 513.8
## 5 22 1 46 2 3 2 35 22.3 99.20 68 16.4 253.7
## 6 22 2 45 2 3 4 52 17.5 81.00 62 13.0 97.9
## 7 22 3 45 2 3 4 52 23.3 108.00 67 15.2 442.7
## 8 22 4 45 3 2 3 54 19.8 106.00 62 15.0 165.3
## 9 23 1 45 1 4 2 54 20.2 98.90 78 15.5 528.6
## 10 23 2 46 1 4 2 49 20.8 99.00 66 15.4 90.3
## 11 23 3 45 2 3 3 49 22.7 99.00 63 14.7 240.7
## 12 23 4 47 1 3 3 57 19.0 86.00 57 13.7 376.6
## 13 24 1 46 3 4 4 43 22.5 92.00 71 13.7 270.1
## 14 24 2 43 1 3 4 57 16.9 92.00 67 13.3 400.4
## 15 24 3 45 1 3 2 65 16.9 90.00 62 13.7 439.8
## 16 24 4 46 2 3 3 67 20.3 85.00 69 16.6 209.2
## 17 25 1 43 3 3 3 47 16.9 84.00 66 12.6 259.6
## 18 25 2 38 1 4 2 39 19.0 86.00 68 14.0 364.1
## 19 25 3 40 1 4 2 62 17.6 93.00 67 12.9 408.0
## 20 25 4 40 1 4 2 60 16.2 91.00 75 12.1 521.4
## 21 26 1 44 3 3 3 30 19.7 108.00 74 14.0 89.9
## 22 26 2 40 2 3 3 38 16.0 98.00 52 11.0 422.0
## 23 26 3 40 2 3 3 54 16.9 103.00 63 12.4 550.7
## 24 26 4 40 2 3 3 50 16.3 98.00 58 11.8 454.9
## 25 27 1 40 3 3 4 38 14.2 88.00 58 9.3 510.5
## 26 27 2 40 1 4 2 28 15.2 97.00 68 12.1 716.3
## 27 27 3 40 2 3 3 56 19.7 109.00 72 16.4 1016.2
## 28 27 4 40 1 3 4 68 18.8 96.00 54 13.0 529.8
## 29 28 1 37 1 3 2 28 21.2 103.00 71 15.9 412.1
## 30 28 2 40 2 3 3 32 14.0 92.00 67 11.5 723.9
## 31 28 3 40 1 3 3 26 15.8 96.00 63 12.6 605.8
## 32 28 4 40 2 3 3 61 16.1 102.00 56 12.4 560.7
## 33 29 1 40 2 3 3 45 17.6 96.00 64 13.0 586.7
## 34 29 2 40 1 2 3 49 15.4 95.00 61 11.6 657.1
## 35 29 3 40 3 2 4 32 16.4 92.00 58 12.8 330.5
## 36 29 4 40 2 2 4 62 16.4 94.00 58 11.5 463.0
## 37 30 1 40 3 2 4 27 18.3 98.00 71 13.1 268.1
## 38 30 2 38 3 3 4 43 19.1 101.00 69 13.9 561.4
## 39 30 3 40 2 3 3 50 19.6 111.00 68 15.4 672.6
## 40 30 4 40 3 2 4 60 15.9 92.00 60 14.4 606.2
## 41 31 1 41 1 4 1 25 14.4 86.00 63 11.8 562.1
## 42 31 2 40 1 3 2 56 11.4 75.00 56 8.9 785.9
## 43 31 3 40 1 3 2 52 14.1 89.00 63 11.3 663.9
## 44 31 4 40 1 3 4 69 16.4 100.00 64 15.2 785.0
## 45 32 1 40 1 2 3 20 15.9 91.00 62 12.1 470.0
## 46 32 2 38 1 3 3 34 22.0 112.00 74 16.7 369.1
## 47 32 3 40 1 3 3 43 16.4 94.00 55 13.2 656.3
## 48 32 4 40 1 3 4 69 16.9 103.00 68 13.7 688.2
## 49 33 1 41 1 4 1 46 13.6 82.00 59 11.2 622.6
## 50 33 2 40 1 3 2 21 16.6 96.00 70 13.6 392.0
## 51 33 3 40 1 3 2 69 16.2 94.00 69 13.4 728.4
## 52 33 4 43 1 4 2 57 17.7 81.00 62 13.0 389.1
## 53 34 1 40 1 2 2 26 14.9 89.00 59 11.2 378.5
## 54 34 2 40 1 3 2 52 14.6 96.00 56 11.2 614.8
## 55 34 3 38 1 4 2 55 19.0 103.00 74 15.2 951.4
## 56 34 4 40 1 3 2 41 15.0 88.00 61 12.9 917.0
## 57 35 1 41 1 3 2 42 17.1 100.00 72 13.2 363.4
## 58 35 2 40 2 3 3 43 14.9 99.00 65 11.0 579.7
## 59 35 3 40 1 3 3 48 15.9 99.00 72 12.5 707.2
## 60 35 4 40 1 3 2 57 20.4 103.00 80 16.1 550.2
## 61 36 1 37 1 3 2 22 18.3 100.00 66 14.2 443.1
## 62 36 2 38 1 4 3 57 16.9 92.00 67 13.3 400.4
## 63 36 3 40 1 2 3 44 15.7 96.00 50 11.7 392.2
## 64 36 4 40 2 2 4 60 17.3 97.00 61 13.2 223.9
## 65 37 1 44 2 2 3 30 20.0 106.00 66 14.7 269.1
## 66 37 2 38 3 2 4 20 19.9 106.00 64 15.0 477.0
## 67 37 3 40 3 3 5 31 20.2 111.00 67 15.2 579.1
## 68 37 4 42 3 3 3 56 17.8 99.00 57 13.8 486.6
## 69 38 1 45 2 3 3 40 13.9 83.00 52 10.0 231.3
## 70 38 2 40 2 3 4 50 12.8 72.00 52 10.2 724.0
## 71 38 3 40 1 4 2 76 14.8 89.00 50 10.4 434.1
## 72 38 4 42 1 3 2 65 15.1 81.00 59 12.4 380.8
## 73 39 1 40 1 3 2 30 14.5 79.00 53 12.0 437.7
## 74 39 2 38 1 2 2 27 14.0 80.00 41 11.3 261.3
## 75 39 3 40 1 3 2 39 17.1 88.00 50 12.2 168.3
## 76 39 4 40 1 3 2 43 14.8 69.00 48 12.3 541.9
## 77 40 1 41 1 3 2 47 18.0 98.00 69 14.1 879.0
## 78 40 2 40 1 3 3 47 18.3 99.00 68 14.6 700.0
## 79 40 3 38 1 3 4 33 16.4 1.00 55 109.0 789.6
## 80 40 4 40 1 3 3 51 18.0 1.01 56 131.0 646.4
x = rnorm(100)
y = rnorm(100)
plot(x, y)
plot(x, y,
xlab="100 números quaisquer",
ylab="Outros 100 números",
xlim=c(-2,3),
ylim=c(-3,2),
col="red",
pch=22,
bg="yellow",
tcl=0.4,
las=1,
cex=1.5,
bty="l",
frame = FALSE)
plot(x,
xlab="100 números quaisquer",
ylab="Outros 100 números",
xlim=c(0,100),
ylim=c(-3,3),
col="red",
pch=22,
bg="yellow",
tcl=0.4,
las=1,
cex=1.5,
bty="l",
frame = FALSE)
points(y,col="red",
pch=21,
bg="orange",
cex = 1.5)
z = c(x,y)
lines(z)
w = rep(mean(c(x,z)),100)
lines(w, lwd = 2, col = "red")
barplot(x)
barplot(x, main="Gráficos de barras", xlab="Valores", ylab="Probabilidades",
col="orange",
border="red",
col.axis="blue")
x3 <- rnorm(5000)
hist(x3,freq=TRUE,xlab="",ylab="",main="", breaks = 50)
d = density(x3)
plot(d)
lines(d, col = "blue")
polygon(d, col="red", border="blue")
feijao$REP = as.factor(feijao$REP)
feijao$TRAT = as.factor(feijao$TRAT)
boxplot(feijao$PROD~feijao$TRAT, col = "yellow", las=2, horizontal = T)
medias <- reorder(feijao$TRAT,feijao$PROD, mean)
boxplot(feijao$PROD~medias, col = "yellow", las=2, ylab = "Produção")
medias2 <- by(feijao$PROD, feijao$TRAT, mean)
box = boxplot(feijao$PROD~feijao$TRAT, col = "yellow", las=2)
lines(1:20, medias2)
points(1:20, medias2)
text(1:20, medias2,
labels = formatC(medias2,
format = "f",
digits = 1),
pos = 2, cex = 0.9, col = "red")
slices <- c(10, 12, 4, 16, 8)
lbls <- c("US", "UK", "Australia", "Germany", "France")
pct <- round(slices/sum(slices)*100)
lbls <- paste(lbls, pct) # add percents to labels
lbls <- paste(lbls,"%",sep="") # ad % to labels
pie(slices,labels = lbls, col=rainbow(length(lbls)),
main="Pie Chart of Countries")
library(ggpubr)
## Loading required package: ggplot2
library(ggplot2)
library(reshape2)
##
## Attaching package: 'reshape2'
## The following object is masked from 'package:tidyr':
##
## smiths
wdata = data.frame(
sex = factor(rep(c("F", "M"), each=200)),
weight = c(rnorm(200, 55), rnorm(200, 58)))
ggdensity(wdata, x = "weight",
add = "mean", rug = TRUE,
color = "sex", fill = "sex",
palette = c("#00AFBB", "#E7B800"))
gghistogram(wdata, x = "weight",
add = "mean", rug = TRUE,
color = "sex", fill = "sex",
palette = c("#00AFBB", "#E7B800"))
## Warning: Using `bins = 30` by default. Pick better value with the argument
## `bins`.
a <- data.frame( x=rnorm(20000, 10, 1.9), y=rnorm(20000, 10, 1.2) )
b <- data.frame( x=rnorm(20000, 14.5, 1.9), y=rnorm(20000, 14.5, 1.9) )
c <- data.frame( x=rnorm(20000, 9.5, 1.9), y=rnorm(20000, 15.5, 1.9) )
data <- rbind(a,b,c)
ggplot(data, aes(x=x, y=y) ) +
geom_bin2d() +
theme_bw()
ggplot(data, aes(x=x, y=y) ) +
geom_bin2d(bins = 70) +
scale_fill_continuous(type = "viridis") +
theme_bw()
ggplot(data, aes(x=x, y=y) ) +
stat_density_2d(aes(fill = ..level..), geom = "polygon", colour="white")
ggplot(data, aes(x=x, y=y) ) +
stat_density_2d(aes(fill = ..density..), geom = "raster", contour = FALSE) +
scale_fill_distiller(palette= "Spectral", direction=1) +
scale_x_continuous(expand = c(0, 0)) +
scale_y_continuous(expand = c(0, 0)) +
theme(
legend.position='none'
)
adubo = read.table("Doses_adubo.txt", header = TRUE)
p <- ggboxplot(adubo, x = "dose", y = "len",
color = "dose", palette =c("#00AFBB", "#E7B800", "#FC4E07"),
add = "jitter", shape = "dose")
p
comparacoes <- list( c("0.5", "1"), c("1", "2"), c("0.5", "2"))
p + stat_compare_means(comparisons = comparacoes)
## Warning in wilcox.test.default(c(4.2, 11.5, 7.3, 5.8, 6.4, 10, 11.2, 11.2, :
## cannot compute exact p-value with ties
## Warning in wilcox.test.default(c(4.2, 11.5, 7.3, 5.8, 6.4, 10, 11.2, 11.2, :
## cannot compute exact p-value with ties
## Warning in wilcox.test.default(c(16.5, 16.5, 15.2, 17.3, 22.5, 17.3, 13.6, :
## cannot compute exact p-value with ties
p + stat_compare_means(label.y = 50)
gv = ggviolin(adubo, x = "dose", y = "len", fill = "dose",
palette = c("#00AFBB", "#E7B800", "#FC4E07"),
add = "boxplot", add.params = list(fill = "white"))
gv
Dados.simulados = expand.grid(Gen = factor(1:10), Rep = factor(1:3), Local = factor(1:20), Regiao = c("Norte", "Nordeste", "Sul"))
prod.1 = rnorm(600, mean = 3000, sd = 1000)
prod.2 = rnorm(600, mean = 1500, sd = 500)
prod.3 = rnorm(600, mean = 500, sd = 300)
prod.4 = c(prod.1,prod.2,prod.3)
prod.4 = round(abs(prod.4),digits = 2)
Dados.simulados$Prod = prod.4
Locais = rep(1:60, each = 30)
Dados.simulados$Local = factor(Locais)
prod.ord <- with(Dados.simulados, reorder(Local,Prod, median))
ggplot(Dados.simulados, aes(as.factor(prod.ord), Prod, fill = Regiao)) +
geom_boxplot() +
theme_bw()+
ylab("Produtividade") +
xlab("Locais") +
theme(axis.text.x=element_text(angle=-90),legend.position = c(.2, .8),
legend.text = element_text(size = 17))
data("mtcars")
dados = mtcars
dados$cyl <- as.factor(dados$cyl)
dados$name <- rownames(dados)
ggbarplot(dados, x = "name", y = "mpg",
fill = "cyl", # change fill color by cyl
color = "white", # Set bar border colors to white
palette = "jco", # jco journal color palett. see ?ggpar
sort.val = "desc", # Sort the value in dscending order
sort.by.groups = FALSE, # Don't sort inside each group
x.text.angle = 90 # Rotate vertically x axis texts
)
dados$mpg_z <- (dados$mpg -mean(dados$mpg))/sd(dados$mpg)
dados$mpg_grp <- factor(ifelse(dados$mpg_z < 0, "baixo", "alto"),
levels = c("baixo", "alto"))
ggbarplot(dados, x = "name", y = "mpg_z",
fill = "mpg_grp",
color = "white", # Set bar border colors to white
palette = "jco", # jco journal color palett. see ?ggpar
sort.val = "asc", # Sort the value in ascending order
sort.by.groups = FALSE, # Don't sort inside each group
x.text.angle = 90, # Rotate vertically x axis texts
ylab = "MPG z-score",
xlab = FALSE,
legend.title = "MPG"
)
ggbarplot(dados, x = "name", y = "mpg_z",
fill = "mpg_grp",
color = "white",
palette = "jco",
sort.val = "desc",
sort.by.groups = FALSE,
x.text.angle = 90,
ylab = "MPG z-score",
legend.title = "MPG Group",
rotate = TRUE,
ggtheme = theme_minimal()
)
ggdotchart(dados, x = "name", y = "mpg_z",
color = "cyl", # Color by groups
palette = c("#00AFBB", "#E7B800", "#FC4E07"), # Custom color palette
sorting = "descending", # Sort value in descending order
add = "segments", # Add segments from y = 0 to dots
add.params = list(color = "lightgray", size = 2), # Change segment color and size
group = "cyl", # Order by groups
dot.size = 6, # Large dot size
label = round(dados$mpg_z,1), # Add mpg values as dot labels
font.label = list(color = "white", size = 9,
vjust = 0.5), # Adjust label parameters
ggtheme = theme_pubr() # ggplot2 theme
)+
geom_hline(yintercept = 0, linetype = 2, color = "lightgray")
library(gapminder)
data <- gapminder %>% filter(year=="2007") %>% dplyr::select(-year)
data %>%
arrange(desc(pop)) %>%
mutate(country = factor(country, country)) %>%
ggplot(aes(x=gdpPercap, y=lifeExp, size=pop, color=continent)) +
geom_point(alpha=0.5) +
scale_size(range = c(.1, 24), name="Population (M)")