R/plot_permutation.R

Defines functions plot_permutation

Documented in plot_permutation

# Nice plot permutation function

plot_permutation <- function(data, observed_value, title){
  #making dataset to put in to permutation plot
  pd <- data.frame(i=1:length(data), value=data)
  #plotting the null distribution and observed difference with the observed as a line
  plot <- ggplot(data = pd, mapping = aes(x=value)) + 
    geom_histogram(fill="darkblue", bins=50) +
    geom_vline(color="darkorange",xintercept = as.numeric(observed_value)) + 
    xlab("")+
    ylab("Count")+
    ggtitle(title, "The orange line is the observed value")+
    theme_minimal()
  return(plot)
}
aumath-advancedr2019/Permutation1 documentation built on Nov. 27, 2019, 6:06 a.m.