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

CVe is calculated wrongly #20

Closed
rasmus87 opened this issue Dec 21, 2020 · 3 comments
Closed

CVe is calculated wrongly #20

rasmus87 opened this issue Dec 21, 2020 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@rasmus87
Copy link

rasmus87 commented Dec 21, 2020

CVe gives the wrong result + it gives a warning because of the bind_cols command.

  1. It binds columns together with rows in different orders.
  2. The final calculation is where you multiply by a sum, I think is wrong - but a choice.
    a. You calculate it as stated verbatim in Reyes-Garcia et al. 2006, but I think they made an error when they wrote it. I doesn't make sense or add any information to multiply all the values by the same number.
    b. The way Tardio and Pardo-de-Santayana 2008 quote it is more sensical. Where they don't take the sum. My correction is based on a shift from Reyes-Garcia et al. 2006 verbatim to the interpretation of CV_e (or CV_s as they call it) in Tardio and Pardo-de-Santayana 2008.
    c. The latter interpretation which I suggest would also follow the interpretation in B. Hoffman, T. Gallaher, Importance indices in ethnobotany. Ethnobot. Res. Appl. 5, 201–218 (2007).

I have highlighted the problematic sections below and my suggestions for fixing them.

CVe <- FCs <- UR_UN_FC <- CVe <- URdata <- data_Ci <- data_URs <- URps <- sp_name <- informant <- NULL
URdata <- ethnobotanydata
URS <- URs(URdata)
NUS <- NUs(URdata)
NUS$Uce <- NUS$NUs/ncol(dplyr::select(URdata, -informant, -sp_name))
FCS <- FCs(URdata)
FCS$Ice <- FCS$FCs/length(unique(URdata$informant))

# ERROR 1:
# REMOVE
# UR_UN_FC <- dplyr::bind_cols(NUS, URS, FCS)
# REPLACE WITH THIS:
UR_UN_FC <- dplyr::left_join(NUS, URS) %>% dplyr::left_join(FCS)

UR_UN_FC$IUce <- UR_UN_FC$URs/length(unique(URdata$informant))

# ERROR 2 (Maybe???)
# REMOVE
# UR_UN_FC$CVe <- UR_UN_FC$Uce * UR_UN_FC$Ice * sum(UR_UN_FC$IUce)
# REPLACE WITH THIS:
UR_UN_FC$CVe <- UR_UN_FC$Uce * UR_UN_FC$Ice * UR_UN_FC$IUce

CVe <- dplyr::select(UR_UN_FC, sp_name, CVe) %>% dplyr::arrange(-CVe) %>% 
  dplyr::mutate(CVe = round(CVe, 3))
as.data.frame(CVe)
@CWWhitney
Copy link
Owner

I think i found the bug here and have corrected it

@CWWhitney CWWhitney self-assigned this Dec 21, 2020
@CWWhitney CWWhitney added the bug Something isn't working label Dec 21, 2020
@rasmus87
Copy link
Author

Looks better now.

@CWWhitney
Copy link
Owner

This issue has been solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants