Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fa_mean doesn't exist #43

Open
jamie-dhoover opened this issue Mar 6, 2023 · 5 comments
Open

fa_mean doesn't exist #43

jamie-dhoover opened this issue Mar 6, 2023 · 5 comments

Comments

@jamie-dhoover
Copy link

The area mean calculation seems to have changed or is throwing an error - any suggestions on how to fix it?

Error in dplyr::select():
! Can't subset columns that don't exist.
✖ Column fa_mean doesn't exist.

Reproducible code:

data(fiaRI)
fiaRI_mr <-clipFIA(fiaRI, mostRecent = T)
#does not work
tpaRI<- tpa(fiaRI_mr)
#works
#tpa(fiaRI_mr, byPlot=T)

If I change the tpa to include byPlot [ tpa(fiaRI_mr, byPlot=T) ] there is not an error.
I need both calculations. Thanks!

@seyounger
Copy link

I am also experiencing this.

@maine-gis-forester
Copy link

same experience here with both CRAN and dev versions.

@brunoks1
Copy link

I got the same error for biomass and area functions.

@brunoks1
Copy link

brunoks1 commented Mar 21, 2023

I found the problem,

somehow, somewhere, fa_mean and fa_var is written as fa_mean_mean and fa_var_var

I worked on the biomass function using trace("biomass",edit=TRUE).

Here was my workaround:

aEst <- aEst %>% dplyr::group_by(!!!aGrpSyms) %>% dplyr::summarize(dplyr::across(dplyr::everything(),
sum, na.rm = TRUE)) %>% dplyr::ungroup() %>% dplyr::select(!!!aGrpSyms,
fa_mean_mean, fa_var_var, nPlots.y)

aEst$fa_mean <- aEst$fa_mean_mean
aEst$fa_var <- aEst$fa_var_var


tEst <- tEst %>% dplyr::group_by(!!!grpSyms) %>% dplyr::summarize(dplyr::across(dplyr::everything(), 
  sum, na.rm = TRUE)) %>% dplyr::ungroup() %>% dplyr::left_join(aEst, 
  by = aGrpBy)

tEst$bPlot_mean <- tEst$bPlot_mean_mean
tEst$cPlot_mean <- tEst$cPlot_mean_mean
tEst$bPlot_var <- tEst$bPlot_var_var
tEst$cPlot_var <- tEst$cPlot_var_var
tEst$bPlot_cv <- tEst$bPlot_cv_cv
tEst$cPlot_cv <- tEst$cPlot_cv_cv


tEst <- tEst %>% dplyr::mutate(BIO_TOTAL = bPlot_mean, 
  CARB_TOTAL = cPlot_mean, AREA_TOTAL = fa_mean, BIO_ACRE = BIO_TOTAL/AREA_TOTAL, 
  CARB_ACRE = CARB_TOTAL/AREA_TOTAL, BIO_TOTAL_VAR = bPlot_var, 
  CARB_TOTAL_VAR = cPlot_var, AREA_TOTAL_VAR = fa_var, 
  BIO_ACRE_VAR = ratioVar(bPlot_mean, fa_mean, bPlot_var, 
    fa_var, bPlot_cv), CARB_ACRE_VAR = ratioVar(cPlot_mean, 
    fa_mean, cPlot_var, fa_var, cPlot_cv), BIO_TOTAL_SE = sqrt(bPlot_var)/BIO_TOTAL * 
    100, CARB_TOTAL_SE = sqrt(cPlot_var)/CARB_TOTAL * 
    100, AREA_TOTAL_SE = sqrt(fa_var)/AREA_TOTAL * 
    100, BIO_ACRE_SE = sqrt(BIO_ACRE_VAR)/BIO_ACRE * 
    100, CARB_ACRE_SE = sqrt(CARB_ACRE_VAR)/CARB_ACRE * 
    100, nPlots_TREE = nPlots.x, nPlots_AREA = nPlots.y, 
  N = P2PNTCNT_EU) %>% dplyr::select(!!!grpSyms, BIO_ACRE, 
  CARB_ACRE, BIO_TOTAL, CARB_TOTAL, AREA_TOTAL, BIO_ACRE_VAR, 
  CARB_ACRE_VAR, BIO_TOTAL_VAR, CARB_TOTAL_VAR, AREA_TOTAL_VAR, 
  BIO_ACRE_SE, CARB_ACRE_SE, BIO_TOTAL_SE, CARB_TOTAL_SE, 
  AREA_TOTAL_SE, nPlots_TREE, nPlots_AREA, N)

@seyounger
Copy link

This appears to be resolved with version 1.0.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants