Skip to content

Commit

Permalink
fix: if statement length #520
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnCoene committed May 5, 2023
1 parent 85324f3 commit b1c3d7a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions R/echarts4r.R
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,15 @@ e_charts.default <- function(

x$mapping$include_x <- FALSE
cl <- x$mapping$x_class
if (cl == "character" || cl == "factor") {
if (any(c("character", "factor") %in% cl)) {
labs <- unique(data[[x$mapping$x]])

if (length(labs) == 1) {
labs <- list(labs)
}

x$opts$baseOption$xAxis <- list(list(data = labs, type = "category", boundaryGap = TRUE))
} else if (cl == "POSIXct" || cl == "POSIXlt" || cl == "Date") {
} else if (any(c("POSIXct", "POSIXlt", "Date") %in% cl)) {
labs <- unique(data[[x$mapping$x]])

if (length(labs) == 1) {
Expand Down
8 changes: 4 additions & 4 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ globalVariables(c("x", "e", ".", "acc", "epoch", "loss", "size", "val_acc", "val
vect <- data[[x]]

if (reorder) {
if (inherits(vect, "numeric") || inherits(vect, "integer")) {
if (any(c(inherits(vect, "numeric"),inherits(vect, "integer")))) {
data <- data[order(data[[x]]), ]
}
}
Expand All @@ -17,7 +17,7 @@ globalVariables(c("x", "e", ".", "acc", "epoch", "loss", "size", "val_acc", "val

for (i in 1:length(data)) {
if (reorder) {
if (inherits(vect, "numeric") || inherits(vect, "integer")) {
if (any(c(inherits(vect, "numeric"), inherits(vect, "integer")))) {
data[[i]] <- data[[i]][order(data[[i]][[x]]), ]
}
}
Expand Down Expand Up @@ -500,9 +500,9 @@ globalVariables(c("x", "e", ".", "acc", "epoch", "loss", "size", "val_acc", "val
.get_type <- function(e, serie) {
cl <- .get_class(e, serie)

if (cl == "character" || cl == "factor") {
if (any(c("character", "factor") %in% cl)) {
"category"
} else if (cl == "POSIXct" || cl == "POSIXlt" || cl == "Date") {
} else if (any(c("POSIXct", "POSIXlt", "Date") %in% cl)) {
"time"
} else {
"value"
Expand Down

0 comments on commit b1c3d7a

Please sign in to comment.