R/calc_ldNe.R

Defines functions calc_ldNe

Documented in calc_ldNe

#' @title Calculate ldNe
#' @description Calculate ldNe for data frame of genotypes
#' 
#' @param x data frame of genotypes as read from simulation replicate .csv file
#' 
#' @return estimated Ne for each stratum in file with lower and upper CIs
#' 
#' @author Eric Archer \email{eric.archer@@noaa.gov}
#' 
#' @export
#'
calc_ldNe <- function(x) {
  x.ne <- x %>% 
    strataG::df2gtypes(ploidy = 2) %>% 
    strataG::ldNe()
  
  if(!is.null(x.ne)) {
    x.ne %>% 
      dplyr::select(.data$stratum, .data$Ne, .data$param.lci, .data$param.uci) %>% 
      stats::setNames(c("stratum", "Ne", "Ne.lci", "Ne.uci"))
  } else NULL
}
EricArcher/ebvSim documentation built on April 9, 2020, 3:39 p.m.