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

RFCs doesn't work if informant is numeric #25

Open
rasmus87 opened this issue Dec 30, 2020 · 2 comments
Open

RFCs doesn't work if informant is numeric #25

rasmus87 opened this issue Dec 30, 2020 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@rasmus87
Copy link

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
@rasmus87
Copy link
Author

rasmus87 commented Dec 30, 2020

Unless we assume that the dataset includes full zero rows for all species not mentioned by an informant you need to change this as well:

RFCs <- RFCdata %>% dplyr::group_by(sp_name) %>% dplyr::summarize(RFCs = sum(FCps/(length(unique(informant))))) %>% 
  dplyr::arrange(-RFCs) %>% dplyr::mutate(RFCs = round(RFCs,  3))

This will solve it:

N <- length(unique(RFCdata$informant))
RFCs <- RFCdata %>% dplyr::group_by(sp_name) %>% dplyr::summarize(RFCs = sum(FCps)/N) %>% 
  dplyr::arrange(-RFCs) %>% dplyr::mutate(RFCs = round(RFCs, 3))

@CWWhitney
Copy link
Owner

I added the 'N' calculation (this is a good addition).

@CWWhitney CWWhitney self-assigned this Jan 4, 2021
@CWWhitney CWWhitney added the enhancement New feature or request label Jan 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants