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

Add vector functions for Kurtosis and Skewness #132

Closed
spsanderson opened this issue Jan 7, 2022 · 1 comment
Closed

Add vector functions for Kurtosis and Skewness #132

spsanderson opened this issue Jan 7, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@spsanderson
Copy link
Owner

hai_kurtosis_vec <- function(.x){
  
  # Tidyeval ----
  x_term <- .x
  
  # Checks ----
  if(!is.numeric(x_term)){
    stop(call. = FALSE, ".x must be a numeric vector.")
  }
  
  # Calculate
  n              <- length(x_term)
  mu             <- mean(x_term, na.rm = TRUE)
  n_diff         <- (x_term - mu)^4
  nu             <- (1/n * sum(n_diff))
  d_diff         <- (x_term - mu)^2
  de             <- (1/n * sum(d_diff))^2
  k              <- nu/de
  return(k)
  print(k)
}

hai_skewness_vec <- function(.x){
  
  # Tidyeval ----
  x_term <- .x
  
  # Checks ----
  if(!is.numeric(x_term)){
    stop(call. = FALSE, ".x must be a numeric vector.")
  }
  
  # Calculate
  n      <- length(x_term)
  mu     <- mean(x_term, na.rm = TRUE)
  n_diff <- (x_term - mu)^3
  nu     <- (1/n * sum(n_diff))
  d_diff <- (x_term - mu)^2
  de     <- (1/n * sum(d_diff))^(3/2)
  s      <- nu/de
  return(s)
  print(s)
}
@spsanderson spsanderson added the enhancement New feature or request label Jan 7, 2022
@spsanderson spsanderson self-assigned this Jan 7, 2022
@spsanderson spsanderson added this to the healthyR.ai 0.0.6 milestone Jan 7, 2022
@spsanderson
Copy link
Owner Author

Use this link for the formula

https://www.geeksforgeeks.org/skewness-and-kurtosis-in-r-programming/

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

1 participant