forked from CristianPessatti/RelatorioEstatComp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlimpeza.R
121 lines (117 loc) · 4.96 KB
/
limpeza.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/usr/bin/env Rscript
library("tidyverse")
library("readxl")
library("magrittr")
colunas = tribble(
~tabela, ~tipo, ~nome, ~legenda,
"Ref. No.", "skip", "", "",
"References", "skip", "", "",
"Sampling date", "skip", "", "",
"Source...4", "skip", "", "",
"Season", "text", "estacao", "Estação",
"Source...6", "skip", "", "",
"Locality", "skip", "", "",
"County", "skip", "municipio", "",
"State", "skip", "estado", "",
"Latitude", "skip", "", "",
"Longitude", "skip", "", "",
"Source...12", "skip", "", "",
"Altitude (m)", "skip", "", "",
"Source...14", "skip", "", "",
"Mean annual precipitation (mm)", "numeric", "precip", "Precipitação média anual",
"Source...16", "skip", "", "",
"Annual mean temperature (°C)", "numeric", "temp", "Temperatura média anual",
"Source...18", "skip", "", "",
"Köppen climate", "text", "clima", "Clima (Köppen)",
"Source...20", "skip", "", "",
"Biome", "text", "bioma", "Bioma",
"Source...22", "skip", "", "",
"Ecosystem", "skip", "", "",
"Source...24", "skip", "", "",
"Native vegetation", "skip", "", "",
"Source...26", "skip", "", "",
"Forestry plantation", "skip", "", "",
"Source...28", "skip", "", "",
"Pasture", "skip", "", "",
"Source...30", "skip", "", "",
"Agricultural crop", "skip", "", "",
"Source...32", "skip", "", "",
"Tillage system", "skip", "", "",
"Source...34", "skip", "", "",
"Current land use (years)", "skip", "", "",
"Source...36", "skip", "", "",
"Previous land use", "skip", "", "",
"Source...38", "skip", "", "",
"Pesticides", "skip", "", "",
"Source...40", "skip", "", "",
"Pesticide type(s)", "skip", "", "",
"Source...42", "skip", "", "",
"Fertilizers", "skip", "", "",
"Fertilizer type(s)", "skip", "", "",
"Source...45", "skip", "", "",
"Fertilizer details", "skip", "", "",
"Source...47", "skip", "", "",
"Soil class (Brazilian classification)", "skip", "s_bras", "",
"FAO soil classification", "skip", "s_fao", "",
"Source...50", "skip", "", "",
"Size of hole (side x side cm)", "skip", "", "",
"Source...52", "skip", "", "",
"Depth of hole (cm)", "skip", "", "",
"Source...54", "skip", "", "",
"No. holes", "skip", "", "",
"Source...56", "skip", "", "",
"Macrofauna sampled", "skip", "", "",
"Total density (indiv. m-2)", "numeric", "dens", "Densidade (indivíduos/m²)",
"Source...59", "skip", "", "",
"Total Biomass (g m-2)", "numeric", "massa", "Massa",
"Source...61", "skip", "", "",
"Species identified (yes / no)", "skip", "", "",
"Source...63", "skip", "", "",
"Soil moisture", "numeric", "humi", "Umidade do solo",
"Source...65", "skip", "", "",
"Depth of chemical analysis (cm)", "skip", "", "",
"Source...67", "skip", "", "",
"pH", "numeric", "pH", "pH do solo",
"Source...69", "skip", "", "",
"H+Al (cmolc dm-3)", "skip", "Al", "",
"Source...71", "skip", "", "",
"K (cmolc dm-3)", "numeric", "K", "K Potássio",
"Source...73", "skip", "", "",
"Ca (cmolc dm-3)", "numeric", "Ca", "Ca Cálcio",
"Source...75", "skip", "", "",
"Mg (cmolc dm-3)", "numeric", "Mg", "Mg Magnésio",
"Source...77", "skip", "", "",
"P (mg dm-3)", "numeric", "P", "P Fósforo",
"Source...79", "skip", "", "",
"C (g dm-3)", "numeric", "C", "C Carbono",
"Source...81", "skip", "", "",
"Sum of bases", "skip", "", "",
"Source...83", "skip", "", "",
"CEC", "skip", "", "",
"Source...85", "skip", "", "",
"Base saturation", "skip", "", "",
"Source...87", "skip", "", "",
"N (g dm-3)", "numeric", "N", "N Nitrogênio",
"Source...89", "skip", "", "",
"C:N ratio", "skip", "", "",
"Source...91", "skip", "", "",
"Sand (g/Kg)", "skip", "", "",
"Source...93", "skip", "", "",
"Clay (g/Kg)", "skip", "", "",
"Source...95", "skip", "", "",
"Silt (g/Kg)", "skip", "", "",
"Source...97", "skip", "", "",
"Texture", "text", "tex", "Textura do solo",
"Source...99", "skip", "", "",
)
worms <- read_xlsx("./Nadolny_etal_Worms_Brazil_DRYAD_9.xlsx", sheet = "Data base", col_types = colunas$tipo)
trans_names <- function(original) {(filter(colunas, tabela %in% original))$nome}
worms %<>% rename_with(trans_names)
worms %<>% mutate(estacao = toupper(estacao))
worms %<>% filter(estacao != "BOTH")
write_excel_csv2(worms, "worms.csv")
trans_names2 <- function(original) {(filter(colunas, nome %in% original))$legenda}
worms2 <- worms %>% rename_with(trans_names2)
legenda = tibble( var = colnames(worms),
legenda = colnames(worms2))
write_excel_csv2(legenda, "legenda.csv")