-
Notifications
You must be signed in to change notification settings - Fork 0
/
.Rhistory
297 lines (297 loc) · 11.7 KB
/
.Rhistory
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
getwd()
#Creating directory
file_path <- here::here("atividade1")
if (!dir.exists(file_path))
dir.create(file_path)
getwd()
file_path
#Downloading
file_name <- "MADERA.csv"
url <- "https://zenodo.org/records/7063870/files/MADERA_Herrera_Alvarez_et_al_2023_v1.csv?download=1"
download.file(url, file.path(file_path, file_name), mode = "wb")
#Loading
MADERA <- readr::read_csv(file.path(file_path, "MADERA.csv"))
View(MADERA)
View(MADERA)
table(MADERA$Accepted_family)
?hist
hist(MADERA$Accepted_family)
?prop.table
barplot(table(MADERA$Accepted_family))
?barplot
#Exploratory bar plot
#Ordering by quantity
ordering <- sort(MADERA$Accepted_family, decreasing = TRUE)
source("~/.active-rstudio-document", echo=TRUE)
#Creating directory
file_path <- here::here("atividade1")
if (!dir.exists(file_path))
dir.create(file_path)
#Downloading
file_name <- "MADERA.csv"
url <- "https://zenodo.org/records/7063870/files/MADERA_Herrera_Alvarez_et_al_2023_v1.csv?download=1"
download.file(url, file.path(file_path, file_name), mode = "wb")
#Loading
MADERA <- readr::read_csv(file.path(file_path, "MADERA.csv"))
#Exploratory bar plot
#Ordering by quantity
ordering <- sort(MADERA$Accepted_family, decreasing = TRUE)
barplot(table(ordering))
1+1
#Exploratory bar plot
#Ordering by quantity
ordering <- sort(MADERA$Accepted_family, decreasing = TRUE)
ordering
barplot(table(ordering))
barplot(table(ordering))
# Barplot with ordered frequencies and add names
barplot(ordered_counts, main = "Animal Counts", xlab = "Animal", ylab = "Count", col = "skyblue")
# Barplot with ordered frequencies and add names
barplot(ordering, main = "Animal Counts", xlab = "Animal", ylab = "Count", col = "skyblue")
table(ordering)
View(MADERA)
#Exploratory bar plot
#Ordering by quantity
ordering <- sort(table(MADERA$Accepted_family), decreasing = TRUE)
barplot(table(ordering))
################################
##### Exploratory bar plot #####
################################
#Getting frequencies
family_freq <- table(MADERA$Accepted_family)
#Ordering frequencies
family_orde <- sort(family_freq, decreasing = TRUE)
################################
##### Exploratory bar plot #####
################################
#Getting frequencies
family_freq <- table(MADERA$Accepted_family)
#Ordering frequencies
family_orde <- sort(family_freq, decreasing = TRUE)
ordering <- sort(table(family_freq, decreasing = TRUE)
################################
##### Exploratory bar plot #####
################################
#Getting frequencies
family_freq <- table(MADERA$Accepted_family)
#Ordering frequencies
family_orde <- sort(family_freq, decreasing = TRUE)
################################
##### Exploratory bar plot #####
################################
#Getting frequencies
family_freq <- table(MADERA$Accepted_family)
#Ordering frequencies
family_orde <- sort(family_freq, decreasing = TRUE)
#Ordered barplot
barplot(family_orde, main = "Animal Counts", xlab = "Animal", ylab = "Count", col = "skyblue")
#Ordered barplot
barplot(family_orde, main = "Most common families", xlab = "Family", ylab = "Frequency", col = "darkred")
#Ordered barplot
barplot(family_orde, main = "Most common families", xlab = "Family", ylab = "Frequency")
#Ordered barplot
barplot(family_orde[1:10], main = "Most common families", xlab = "Family", ylab = "Frequency")
#Ordered barplot
barplot(family_orde, main = "Most common families", xlab = "Family", ylab = "Frequency")
text(x = 1:length(ordered_counts),
y = ordered_counts,
labels = names(ordered_counts),
pos = 3,
cex = 0.8,
col = "red")
text(x = 1:length(family_orde),
y = family_orde,
labels = names(family_orde),
pos = 3,
cex = 0.8,
col = "red")
#Ordered barplot
barplot(family_orde, main = "Most common families", xlab = "Family", ylab = "Frequency")
text(x = 1:length(family_orde),
y = family_orde,
labels = names(family_orde))
#Ordered barplot
barplot(family_orde[1:15], main = "Most common families", xlab = "Family", ylab = "Frequency")
text(x = 1:length(family_orde)[1:15],
y = family_orde,
labels = names(family_orde))
#Ordered barplot
barplot(family_orde[1:15], main = "Most common families", xlab = "Family", ylab = "Frequency")
text(x = 1:length(family_orde[1:15]),
y = family_orde,
labels = names(family_orde))
#Ordered barplot
barplot(family_orde[1:15], main = "Most common families", xlab = "Family", ylab = "Frequency")
text(x = 1:length(family_orde[1:15]),
y = family_orde,
labels = names(family_orde[1:15]))
#Ordered barplot
barplot(family_orde[1:15], main = "Most common families", xlab = "Family", ylab = "Frequency")
text(x = 1:length(family_orde[1:15]),
y = family_orde[1:15],
labels = names(family_orde[1:15]))
#Ordered barplot
barplot(family_orde[1:15], main = "Most common families", xlab = "Family", ylab = "Frequency")
#Ordered barplot
barplot(family_orde, main = "Most common families", xlab = "Family", ylab = "Frequency")
#Ordered barplot
barplot(family_orde[1:5], main = "Most common families", xlab = "Family", ylab = "Frequency")
#Ordered barplot
barplot(family_orde, main = "Most common families", xlab = "Family", ylab = "Frequency")
barplot(family_orde[1:5], main = "Most common families", xlab = "Family", ylab = "Frequency")
family_orde
#How much do they represent overall?
sum(family_orde)
#How much do they represent overall?
sum(family_orde[1:5])/sum(family_orde)
names(MADERA)
##### Some simple linear regression just for the sake... #####
plot(estimated_ind_Amazon ~ number_individuals_ATDN_plots, data = MADERA)
##### Some simple linear regression just for the sake... #####
plot(MADERA$estimated_ind_Amazon, MADERA$number_individuals_ATDN_plots, pch = 19)
##### Some simple linear regression just for the sake... #####
plot(MADERA$estimated_ind_Amazon, MADERA$number_individuals_ATDN_plots,
pch = 19, cex = 0.5)
##### Some simple linear regression just for the sake... #####
plot(x = MADERA$number_individuals_ATDN_plots, y = MADERA$estimated_ind_Amazon,
pch = 19, cex = 0.5, xlab = "Es")
##### Some simple linear regression just for the sake... #####
plot(x = MADERA$number_individuals_ATDN_plots, y = MADERA$estimated_ind_Amazon,
pch = 19, cex = 0.5, xlab = "Observed", ylab = "Estimated")
abline(lm(MADERA$estimated_ind_Amazon ~ MADERA$number_individuals_ATDN_plots, "red"))
abline(lm(MADERA$estimated_ind_Amazon ~ MADERA$number_individuals_ATDN_plots))
abline(lm(MADERA$estimated_ind_Amazon ~ MADERA$number_individuals_ATDN_plots, col = 'red'))
abline(lm(MADERA$estimated_ind_Amazon ~ MADERA$number_individuals_ATDN_plots, color = 'red'))
abline(lm(MADERA$estimated_ind_Amazon ~ MADERA$number_individuals_ATDN_plots, col = 'red'))
abline(lm(MADERA$estimated_ind_Amazon ~ MADERA$number_individuals_ATDN_plots), col = 'red')
View(MADERA)
##### Some simple linear regression just for the sake... #####
lm_model <- lm(MADERA$estimated_ind_Amazon ~ MADERA$number_individuals_ATDN_plots)
lm_summa <- summary(lm)
lm_summa <- summary(lm_model)
abline(lm_summa$coefficients)
plot(x = MADERA$number_individuals_ATDN_plots, y = MADERA$estimated_ind_Amazon,
pch = 19, cex = 0.5, xlab = "Observed", ylab = "Estimated")
abline(lm_model)
abline(lm_model, col = "red", cex = 2)
##### Some simple linear regression just for the sake... #####
lm_model <- lm(MADERA$estimated_ind_Amazon ~ MADERA$number_individuals_ATDN_plots)
lm_summa <- summary(lm_model)
plot(x = MADERA$number_individuals_ATDN_plots, y = MADERA$estimated_ind_Amazon,
pch = 19, cex = 0.5, xlab = "Observed", ylab = "Estimated")
abline(lm_summa$coefficients)
abline(lm_model$coefficients)
abline(lm_model$coefficients, color = "red")
plot(x = MADERA$number_individuals_ATDN_plots, y = MADERA$estimated_ind_Amazon,
pch = 19, cex = 0.5, xlab = "Observed", ylab = "Estimated")
abline(lm_model$coefficients, color = "red")
abline(lm_model$coefficients, col = "red")
abline(lm_model$coefficients, col = "red", lwd = 2)
lm_model
lm_summa$adj.r.squared
text(x = 500, y = 4e+09, 'cu')
text(x = 500, y = 4e+09, 'cu')
plot(x = MADERA$number_individuals_ATDN_plots, y = MADERA$estimated_ind_Amazon,
pch = 19, cex = 0.5, xlab = "Observed", ylab = "Estimated")
abline(lm_model$coefficients, col = "red", lwd = 2)
text(x = 500, y = 4e+09, 'cu')
plot(x = MADERA$number_individuals_ATDN_plots, y = MADERA$estimated_ind_Amazon,
pch = 19, cex = 0.5, xlab = "Observed", ylab = "Estimated")
abline(lm_model$coefficients, col = "red", lwd = 2)
#Plot parameters
plot(x = MADERA$number_individuals_ATDN_plots, y = MADERA$estimated_ind_Amazon,
pch = 19, cex = 0.5,
xlab = "Observed",
ylab = "Estimated",
main = "Observed vs. Estimated number of trees for each timber species")
abline(lm_model$coefficients, col = "red", lwd = 2)
?text
text(x = 500, y = 4e+09, round(lm_summa$adj.r.squared, 3))
#Plot parameters
plot(x = MADERA$number_individuals_ATDN_plots, y = MADERA$estimated_ind_Amazon,
pch = 19, cex = 0.5,
xlab = "Observed",
ylab = "Estimated",
main = "Observed vs. Estimated number of trees for each timber species")
abline(lm_model$coefficients, col = "red", lwd = 2)
text(x = 500, y = 4e+09, paste0("R²=", round(lm_summa$adj.r.squared, 3))
text(x = 500, y = 4e+09, paste0("R²=", round(lm_summa$adj.r.squared, 3)))
#Plot parameters
plot(x = MADERA$number_individuals_ATDN_plots, y = MADERA$estimated_ind_Amazon,
pch = 19, cex = 0.5,
xlab = "Observed",
ylab = "Estimated",
main = "Observed vs. Estimated number of trees for each timber species")
abline(lm_model$coefficients, col = "red", lwd = 2)
text(x = 500, y = 4e+09, paste0("R²=", round(lm_summa$adj.r.squared, 3)))
#Plot parameters
plot(x = MADERA$number_individuals_ATDN_plots, y = MADERA$estimated_ind_Amazon,
pch = 19, cex = 0.5,
xlab = "Observed",
ylab = "Estimated",
main = "Observed vs. Estimated number of trees for each timber species")
abline(lm_model$coefficients, col = "red", lwd = 2)
text(x = 500, y = 4e+09, paste0("R² = ", round(lm_summa$adj.r.squared, 3)))
#Creating directory
file_path <- here::here("atividade1")
if (!dir.exists(file_path))
dir.create(file_path)
#Downloading
file_name <- "MADERA.csv"
url <- "https://zenodo.org/records/7063870/files/MADERA_Herrera_Alvarez_et_al_2023_v1.csv?download=1"
download.file(url, file.path(file_path, file_name), mode = "wb")
#Loading
MADERA <- readr::read_csv(file.path(file_path, "MADERA.csv"))
View(MADERA)
################################
##### Exploratory bar plot #####
################################
#Getting frequencies
family_freq <- table(MADERA$Accepted_family)
#Ordering frequencies
family_orde <- sort(family_freq, decreasing = TRUE)
#Ordered barplot
barplot(family_orde, main = "Most common families", xlab = "Family", ylab = "Frequency")
################################
##### Exploratory bar plot #####
################################
#Getting frequencies
family_freq <- table(MADERA$Accepted_family)
family_freq
family_orde
#Ordered barplot
barplot(family_orde, main = "Most common families", xlab = "Family", ylab = "Frequency")
barplot(family_orde[1:5], main = "Most common families", xlab = "Family", ylab = "Frequency")
#How much do they represent overall?
sum(family_orde[1:5])/sum(family_orde) #41% of all timber species
?download.file
#Creating directory
file_path <- here::here("atividade1")
#Downloading
file_name <- "MADERA.csv"
file.path(file_path, file_name)
?file.path
?download.file
getwd()
# Define working directory
setwd("/cloud/project/LCF5900")
# Define github URL where climate data from Piracicaba is stored
url_1 <- "https://github.com/FlorestaR/dados/blob/main/X_PIRACLIM"
xls_2 <- "DadosClima_Piracicaba.csv"
prm_3 <- "?raw=true"
gitFile <- file.path(url_1, xls_2) %>% paste0(prm_3)
# Define github URL where climate data from Piracicaba is stored
library(tidyverse)
gitFile <- file.path(url_1, xls_2) %>% paste0(prm_3)
# Downloads Excel table as a tibble (dataframe) from github
df <- read.csv(gitFile, sep=";") %>% tibble() # import
getwd()
getwd()
#Creating directory
file_path <- here::here("atividade1")
#Downloading
file_name <- "MADERA.csv"
#Loading
MADERA <- readr::read_csv(file.path(file_path, "MADERA.csv"))
View(MADERA)
getwd()