Skip to content

Commit

Permalink
ts_ggplot: pass symbols, not strings (fix #223)
Browse files Browse the repository at this point in the history
  • Loading branch information
christophsax committed Sep 14, 2023
1 parent abbdcfc commit d8bf6dc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: tsbox
Type: Package
Title: Class-Agnostic Time Series
Version: 0.4.1
Version: 0.4.1.9001
Authors@R: c(
person("Christoph", "Sax", email = "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-7192-7044")),
person("Cathy", "Chamberlin", role = c("rev")),
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# tsbox 0.4.1.9001

- ts_ggplot: pass symbols, not strings (fix #223)


# tsbox 0.4.1 (2023-05-06)

## Bug fixes
Expand Down
7 changes: 5 additions & 2 deletions R/ts_ggplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,13 @@ ts_ggplot <- function(..., title, subtitle, ylab = "") {

n <- NCOL(df)
stopifnot(n > 1L)
stime <- as.name(cname$time)
svalue <- as.name(cname$value)

if (n == 2L) {
p <- ggplot2::ggplot(
df,
ggplot2::aes(x = !! cname$time, y = !! cname$value)
ggplot2::aes(x = !! stime, y = !! svalue)
)
} else if (n > 2) {

Expand All @@ -87,7 +90,7 @@ ts_ggplot <- function(..., title, subtitle, ylab = "") {
}
p <- ggplot2::ggplot(
df,
ggplot2::aes(x = !! cname$time, y = !! cname$value, color = cname$id)
ggplot2::aes(x = !! stime, y = !! svalue)
)
}
p <- p + ggplot2::geom_line()
Expand Down

1 comment on commit d8bf6dc

@p-wegmueller
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe deleting color = cname$id should be undone for n >= 2

Maybe something like

sid <- as.factor(as.name(cname$id)) ggplot2::aes(x = !! stime, y = !! svalue, color = sid)
would do the trick

Please sign in to comment.