cwwhitney / ethnobotanyr Goto Github PK
View Code? Open in Web Editor NEWR package for quantitative ethnobotany
R package for quantitative ethnobotany
We discussed the incorporation of spatial analysis. Maybe a tall order but we should at least think about it.
The papers:
Harou et al. - 2020 - Mapping Flood-Based Farming Systems with Bayesian .pdf
Liman Harou et al. - 2021 - Crop modelling in data-poor environments โ A knowl.pdf
Start with Eight to Late
https://eight2late.wordpress.com/2015/05/27/a-gentle-introduction-to-text-mining-using-r/
FLs is calculated correctly, as in the cited paper. But it is stated wrongly in the vignette.
Where it states URs it should state FCs instead, as this is what you actually do.
It should also state that the values are multiplied by 100, both in the vignette and in the help file.
@CWWhitney, Thank you for the development of the package! Is it possible to change the colors? which function do you use to change the colors of the CIs-plot?
Originally posted by @KamilaBio in #21 (comment)
The calculation of both CIs UVs and simple UVs seems over excessive.
They all calculate the exact same thing correctly - but it seems error prone to do it in three different ways.
All three implementations calculate the exact same thing, and I would suggest using only one function and letting the other functions just refer to that one function.
The implementation of CIs looks cleanest and I would suggest the others just pointed to that.
Due to the use of this function:
RFCdata <- RFCdata %>% dplyr::mutate_if(is.numeric, ~1 *
(. != 0))
The function doesn't work if the informant column is numeric. I am afraid that this error might occur elsewhere as well, but I have not come across it so far.
The line can simply be replaced with, which would work:
RFCdata$FCps <- (RFCdata$FCps > 0) * 1
CVe gives the wrong result + it gives a warning because of the bind_cols command.
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)
Add more functions
Quantitative methods in ethnobotany and ethnopharmacology: considering the overall flora--hypothesis testing for over- and underused plant families with the Bayesian approach.
https://www.ncbi.nlm.nih.gov/pubmed/21767623
Spiritual and ceremonial plants in North America: an assessment of Moerman's ethnobotanical database comparing Residual, Binomial, Bayesian and Imprecise Dirichlet Model (IDM) analysis.
All functions seem to return a result using as.data.frame(...)
.
The built in example dataset is also a data frame class.
Since the package is marketed as an intended expansion package working with tidyverse is should probably be updated to tibbles.
The code doesn't seem to calculate the Relative Importance Index as in the paper you cite.
I think the RFCs(max) part of the code is wrong.
Your code says:
RFCs <- RFCdata %>% dplyr::group_by(sp_name) %>% dplyr::summarize(RFCs = sum(FCps/(length(unique(informant))))) %>% dplyr::arrange(-RFCs)
Which gives FCs
over total number of informants not over the max(FCs)
. There are 20 unique
informants for all species in the test dataset, even though not all of them mention all species.
For the test dataset your code gives this:
> ethnobotanyR::RIs(ethnobotanydata)
sp_name RIs
1 sp_c 0.925
2 sp_a 0.812
3 sp_d 0.800
4 sp_b 0.738
while the RI should be:
> RFCsmax <- FCs(ethnobotanydata) %>% mutate(RFCsmax = FCs/max(FCs))
> RNUsmax <- NUs(ethnobotanydata) %>% mutate(RNUsmax = NUs/max(NUs))
>
> RI <- left_join(RFCsmax, RNUsmax, by = "sp_name")
> RI %>% mutate(RIs = (RFCsmax + RNUsmax) / 2) %>% arrange(desc(RIs))
sp_name FCs RFCsmax NUs RNUsmax RIs
1 sp_c 17 1.0000000 8 1.000 1.0000000
2 sp_a 15 0.8823529 7 0.875 0.8786765
3 sp_d 12 0.7058824 8 1.000 0.8529412
4 sp_b 12 0.7058824 7 0.875 0.7904412
I have spent some time trying to understand this discrepancy. If I have misunderstood the paper or your function please let me know. I am teaching a course next month using your package and before i confuse my students too much, I would like to know if I'm mistaken or the package has a bug.
If I am right your code could read:
RFCs <- RFCdata %>% dplyr::group_by(sp_name) %>% dplyr::summarize(FCs = sum(FCps)) %>%
mutate(RFCs = FCs/max(FCs), FCs = NULL) %>%
dplyr::arrange(-RFCs)
Suggest a tutorial / training how to use the package related to ethnobotany cf. https://www.youtube.com/watch?v=QPdJNqXHxmI&lc=Ugw3YEztKdXhdtrv0mF4AaABAg
Look at possible ways to use area curves and time curves for quantitative analysis.
Read IPBES and make links (this as protocol)
Since the package is marketed as an addition to tidyverse, I think it is important all functions work with tibbles.
The function FLs()
doesn't work with tibbles due to the functions use of reshape::melt(...)
.
The easiest fix (but not the best) is simply to replace reshape
with reshape2
.
The function could be rewritten to be based on tidyverse functions, to avoid problems like this.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.