Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. fx_str <- function(x,
  2. col_time,
  3. col_group,
  4. col_outcome,
  5. period = 24,
  6. alpha_threshold = 0.05,
  7. timeout_n = 10000){
  8.  
  9. if(!"ggplot2" %in% installed.packages()[, "Package"]){
  10. return(message("Please install 'ggplot2'"))
  11. }
  12.  
  13. library(ggplot2)
  14. colnames(x)[agrep(col_group, colnames(x))] <- "group"
  15.  
  16. if(length(levels(as.factor(x$group))) != 2){
  17. return(message("Your grouping variable had more or less than 2 levels! \nThis function is used to compare two groups of data. \nTo avoid me having to guess, please send data with only two possible values in your grouping variable to this function."))
  18. }
  19.  
  20. group_1_text <- levels(as.factor(x$group))[1]
  21. group_2_text <- levels(as.factor(x$group))[2]
  22. colnames(x)[agrep(col_time, colnames(x))] <- "time"
  23.  
  24. #if(!class(x$time) %in% c("numeric", "integer")){
  25. # return(message(paste("The time variable which you gave was a '",
  26. # class(x$time),
  27. # "' \nThis function expects time to be given as hours and be of class 'integer' or 'numeric'.",
  28. # "\nPlease convert the time variable in your dataframe to be of one of these classes",
  29. # sep = "")))
  30. #}
  31.  
  32. colnames(x)[agrep(col_outcome, colnames(x))] <- "measure"
  33.  
  34. #if(!class(x$measure) %in% c("numeric", "integer")){
  35. # return(message(paste("The measure variable which you gave was a '",
  36. # class(x$measure),
  37. # "' \nThis function expects measure to be number and be of class 'integer' or 'numeric'.",
  38. # "\nPlease convert the measure variable in your dataframe to be of one of these classes",
  39. # sep = "")))
  40. #}
  41.  
  42. return(str(x))
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement