Remove code repetition in `specific_plotting_dynamic.R`

Đang mở
#46 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
r
Lĩnh vực
data-visualization

Hướng nghiên cứu

Start by reading specific_plotting_dynamic.R and identify the plotting functions that repeat observation and error-bar aesthetics. The work is done when a generic add_obs function adds observations and Obs_SD error bars, and those aesthetics are no longer repeated in the plotting layers.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

refacto

In specific_plotting_dynamic.R, we can remove code repetition by putting all aes into the parent call (the ggplot()). This way we can remove the aes from the geom_line, geom_points and geom_errorbar, and put them in a more generic function that we would call similarly in all plotting functions:

Example, instead of:

p <- ggplot2::ggplot(
    df_data,
    ggplot2::aes(x = .data$Date, colour = .data$variable)
  ) +
    ggplot2::geom_line(ggplot2::aes(y = .data$Simulated)) +
    ggplot2::facet_wrap(~ .data$group_var, scales = "free") +
    ggplot2::labs(shape = "Variable", colour = "Variable")

  if ("Observed" %in% colnames(df_data)) {
    p <- p + ggplot2::geom_point(
      ggplot2::aes(y = .data$Observed, shape = .data$variable),
      na.rm = TRUE
    )
    if ("Obs_SD" %in% colnames(df_data)) {
      p <- p +
        ggplot2::geom_errorbar(
          ggplot2::aes(
            ymin = .data$Observed - 2 * .data$Obs_SD,
            ymax = .data$Observed + 2 * .data$Obs_SD,
            shape = .data$version
          ),
          na.rm = TRUE
        )
    }
  }

We would do:

p <- ggplot2::ggplot(
    df_data,
    ggplot2::aes(x = .data$Date, colour = .data$variable, shape = .data$variable)
  ) +
    ggplot2::geom_line(ggplot2::aes(y = .data$Simulated)) +
    ggplot2::facet_wrap(~ .data$group_var, scales = "free") +
    ggplot2::labs(shape = "Variable", colour = "Variable")

p <- add_obs(p)

With the add_obs function the function above that adds obs and obs_sd.

Ngôn ngữ chính
R
Star
1
Fork
3
Merge trung bình
9 giờ 41 phút
Pull request đã merge (30 ngày)
2

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của SticsRPacks/CroPlotR

Tất cả issue của SticsRPacks/CroPlotR

Issue tương tự

Thêm issue về R

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.