From fd6e2b5f0cfa73a31f87766d2a3bde3cae93cb24 Mon Sep 17 00:00:00 2001 From: SYOUNG9836 Date: Sun, 1 Dec 2024 04:33:38 +0900 Subject: [PATCH] knfi 1.0.1.0009 --- R/biomass_nfi.R | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/R/biomass_nfi.R b/R/biomass_nfi.R index 6e78080..e731d3a 100644 --- a/R/biomass_nfi.R +++ b/R/biomass_nfi.R @@ -384,18 +384,18 @@ biomass_nfi <- function(data, byplot= FALSE, plotgrp=NULL, treegrp= NULL, contin # 2.1.1 Double sampling for post-strat(by forest stand) weight_plotgrp <- data$plot %>% - group_by(!!!plotgrp) %>% - summarise(plot_num_all = n(),.groups = 'drop') + group_by(CYCLE, !!!plotgrp) %>% + summarise(plot_num_all = n_distinct(!!plot_id),.groups = 'drop') weight_year <- data$plot %>% group_by(CYCLE, INVYR, !!!plotgrp) %>% - summarise(plot_num_year = n(),.groups = 'drop') + summarise(plot_num_year = n_distinct(!!plot_id),.groups = 'drop') weight_stand <- data$plot %>% group_by(CYCLE, INVYR, !!strat, !!!plotgrp) %>% - summarise(plot_num_stand = n(),.groups = 'drop') + summarise(plot_num_stand = n_distinct(!!plot_id),.groups = 'drop') weight_DSS <- full_join(weight_stand, weight_year, by =c("CYCLE", "INVYR", as.character(unlist(lapply(plotgrp, quo_name))))) @@ -477,7 +477,7 @@ biomass_nfi <- function(data, byplot= FALSE, plotgrp=NULL, treegrp= NULL, contin # 2.1.4 Weighted Moving Average(to combine annual inventory field data) - weight_WMA <- full_join(weight_year, weight_plotgrp, by =c(as.character(unlist(lapply(plotgrp, quo_name))))) + weight_WMA <- full_join(weight_year, weight_plotgrp, by =c("CYCLE", as.character(unlist(lapply(plotgrp, quo_name))))) weight_WMA$weight_WMA <- weight_WMA$plot_num_year/weight_WMA$plot_num_all @@ -783,17 +783,17 @@ biomass_tsvis <- function(data, plotgrp=NULL, treegrp=NULL, strat="FORTYP_SUB", # 2.1.1 Double sampling for post-strat(forest stand) weight_plotgrp <- data$plot %>% # not CYCLE group_by(!!!plotgrp) %>% - summarise(plot_num_all = n(),.groups = 'drop') + summarise(plot_num_all = n_distinct(!!plot_id),.groups = 'drop') weight_year <- data$plot %>% group_by(CYCLE, INVYR, !!!plotgrp) %>% - summarise(plot_num_year = n(),.groups = 'drop') + summarise(plot_num_year = n_distinct(!!plot_id),.groups = 'drop') weight_stand <- data$plot %>% group_by(CYCLE, INVYR, !!strat, !!!plotgrp) %>% - summarise(plot_num_stand = n(),.groups = 'drop') + summarise(plot_num_stand = n_distinct(!!plot_id),.groups = 'drop') weight_DSS <- full_join(weight_stand, weight_year, by =c("CYCLE", "INVYR", as.character(unlist(lapply(plotgrp, quo_name)))))