
generate_uniform_dataset <- function(
  dataset_size = 20,
  min_x = 0,
  max_x = 5,
  outliers = 2,
  seed = NULL) {
  set.seed(seed)
  
  dt <- data.frame(
    x = round(runif(dataset_size, min = min_x, max = max_x), 2),
    y = round(runif(dataset_size, min = min_x, max = max_x), 2),
    group = "group1",
    stringsAsFactors = F
  )
  
  dt$group[sample(1:dataset_size, outliers)] <- "group2"
  dt
}


make_oscillate <- function(dt, group_sel, size) {
  dt <- dt %>%
    mutate(
      oscillate = ifelse(group == group_sel, 0, size),
      time = 1
    )
  
  dt1 <- dt %>%
    mutate(
      y = y + oscillate,
      time = 2
    )
  
  dt2 <- dt %>%
    mutate(
      y = y,
      time = 3
    )
  
  dt3 <- dt %>%
    mutate(
      y = y - oscillate,
      time = 4
    )
  
  bind_rows(dt, dt1, dt2, dt3)
}

theme_minimal_grid <- function(base_size = 11,
                                        base_family = "",
                                        base_line_size = base_size / 22,
                                        base_rect_size = base_size / 22) {
  
  half_line <- base_size / 2
  
  theme_minimal(base_size = base_size, 
                base_family = base_family,
                base_line_size = base_line_size,
                base_rect_size = base_rect_size) %+replace%
    theme(
      plot.margin = margin(half_line/2, 1.5, half_line/2, 1.5),
      complete = TRUE
    )
}
