Skip to content

[Code Quality] Use of deprecated aes() with external data frame columns #10

@loganylchen

Description

@loganylchen

Description

R/GuitarPlot.R 中,aes() 调用直接引用了data frame的列名,这在ggplot2中是不推荐的做法:

# 第150行
p <- ggplot(densityCI, aes(x = densityCI$x))  # 不推荐

# 第151行
p <- p + geom_line(aes(y = density, colour = samples), ...)

# 第154-155行
p <- p + geom_line(aes(y = densityCI$confidenceDown, ...))  # 混合使用
p <- p + geom_line(aes(y = densityCI$confidenceUp, ...))

Impact

  • ggplot2警告信息
  • 代码风格不一致
  • 可能在某些ggplot2版本中产生问题

Suggested Fix

统一使用列名而非 data$column 格式:

p <- ggplot(densityCI, aes(x = x))
p <- p + geom_line(aes(y = confidenceDown, colour = samples), ...)
p <- p + geom_line(aes(y = confidenceUp, colour = samples), ...)

File

R/GuitarPlot.R lines 150-159

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions