Commit 44859e5a authored by Daniel Falster's avatar Daniel Falster
Browse files

update function for processing big plots to output csv

No related merge requests found
Showing with 20 additions and 21 deletions
+20 -21
......@@ -344,14 +344,10 @@ fun.data.per.ecoregion <- function(ecoregion, data.tot, weight.full.plot, site.n
if (sum(!data.BA.sp[["obs.id"]] == data[["obs.id"]]) > 0)
stop("competition index not in the same order than data")
#####
data.traits = NA
## ADD TRY DATA IF NEEDED
data.TRAITS.s <- NA
if (is.data.frame(data.TRAITS))
data.TRAITS.s <- subset(data.TRAITS, subset = data.TRAITS[[sp.code]] %in%
data[[sp.code2]]) else data.TRAITS.s <- NA
data.TRAITS.s <- subset(data.TRAITS, subset = data.TRAITS[[sp.code]] %in% data[[sp.code2]])
write.csv(data, file = file.path(path, "data.tree.csv"), quote = FALSE, row.names = FALSE)
write.csv(data.BA.sp, file = file.path(path, "data.BA.SP.csv"), quote = FALSE,
......@@ -363,10 +359,12 @@ fun.data.per.ecoregion <- function(ecoregion, data.tot, weight.full.plot, site.n
####### FUNCTION TO FORMAT DATA FOR BIG TROPICAL PLOT
fun.data.per.bigplot <- function(data, site.name, data.TRAITS = NA, Rlim = 15, xy.name,
parallel = FALSE, rpuDist = FALSE, sp.code = "sp", sp.code2 = "sp") {
parallel = FALSE, rpuDist = FALSE, sp.code = "sp", sp.code2 = "sp", out.dir = "output/processed/") {
require(data.table)
dir.create(paste("output/processed/", site.name, sep = ""), recursive = TRUE,
showWarnings = FALSE)
path <- file.path(out.dir, site.name)
dir.create(path, recursive = TRUE, showWarnings = FALSE)
data$sp <- factor(data$sp)
data.TRAITS$sp <- factor(data.TRAITS$sp)
print(paste("plots :", unique(data[["plot"]])))
......@@ -399,18 +397,19 @@ fun.data.per.bigplot <- function(data, site.name, data.TRAITS = NA, Rlim = 15, x
if (sum(!as.character(data.BA.SP[["obs.id"]]) == as.character(data[["obs.id"]])) >
0)
stop("competition index not in the same order than data")
##### ADD TRY DATA OR TRAITS IF NEEDED
if (is.data.frame(data.TRAITS)) {
data.TRAITS.s <- subset(data.TRAITS, subset = data.TRAITS[[sp.code]] %in%
data[[sp.code2]])
list.temp <- list(data.tree = data, data.BA.SP = data.BA.SP, data.traits = data.TRAITS.s)
saveRDS(list.temp, file = paste("output/processed/", site.name, "/list.rds",
sep = ""))
} else {
list.temp <- list(data.tree = data, data.BA.SP = data.BA.sp, data.traits = NA)
saveRDS(list.temp, file = paste("output/processed/", site.name, "/list.rds",
sep = ""))
}
browser()
## ADD TRY DATA IF NEEDED
data.TRAITS.s <- NA
if (is.data.frame(data.TRAITS))
data.TRAITS.s <- subset(data.TRAITS, subset = data.TRAITS[[sp.code]] %in% data[[sp.code2]])
write.csv(data, file = file.path(path, "data.tree.csv"), quote = FALSE, row.names = FALSE)
write.csv(data.BA.sp, file = file.path(path, "data.BA.SP.csv"), quote = FALSE,
row.names = FALSE)
write.csv(data.TRAITS.s, file = file.path(path, "data.traits.csv"), quote = FALSE,
row.names = FALSE)
}
process_inventory_dataset <- function(set, path.formatted = "output/formatted", path.processed = "output/processed"){
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment