Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

66 wiersze
1.4KB

  1. generate_uniform_dataset <- function(
  2. dataset_size = 20,
  3. min_x = 0,
  4. max_x = 5,
  5. outliers = 2,
  6. seed = NULL) {
  7. set.seed(seed)
  8. dt <- data.frame(
  9. x = round(runif(dataset_size, min = min_x, max = max_x), 2),
  10. y = round(runif(dataset_size, min = min_x, max = max_x), 2),
  11. group = "group1",
  12. stringsAsFactors = F
  13. )
  14. dt$group[sample(1:dataset_size, outliers)] <- "group2"
  15. dt
  16. }
  17. make_oscillate <- function(dt, group_sel, size) {
  18. dt <- dt %>%
  19. mutate(
  20. oscillate = ifelse(group == group_sel, 0, size),
  21. time = 1
  22. )
  23. dt1 <- dt %>%
  24. mutate(
  25. y = y + oscillate,
  26. time = 2
  27. )
  28. dt2 <- dt %>%
  29. mutate(
  30. y = y,
  31. time = 3
  32. )
  33. dt3 <- dt %>%
  34. mutate(
  35. y = y - oscillate,
  36. time = 4
  37. )
  38. bind_rows(dt, dt1, dt2, dt3)
  39. }
  40. theme_minimal_grid <- function(base_size = 11,
  41. base_family = "",
  42. base_line_size = base_size / 22,
  43. base_rect_size = base_size / 22) {
  44. half_line <- base_size / 2
  45. theme_minimal(base_size = base_size,
  46. base_family = base_family,
  47. base_line_size = base_line_size,
  48. base_rect_size = base_rect_size) %+replace%
  49. theme(
  50. plot.margin = margin(half_line/2, 1.5, half_line/2, 1.5),
  51. complete = TRUE
  52. )
  53. }