在 ggplot2 中使用 sitools 时的“NANA”输出

xav*_*xav 5 r ggplot2

我使用 sitools 来格式化 ggplot2 图表上的刻度标签。当我处理大量数字时,最大的主要刻度标签最终是“NANA”,并且控制台中会显示一条警告消息:

Warning message:
  In number/sifactor[ix] :
  longer object length is not a multiple of shorter object length
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

library(ggplot2)
library(sitools)

data <- data.frame(list(
 Quarter=as.factor(c("Q1 2015","Q2 2015","Q3 2015","Q4 2015","Q1 2016")),
 Operations=c(23000000,54000000,120000000,450000000,12000000)
))

line_chart <- function(df, x, y, tit, xtit, ytit) {
  return(
    df %>% ggplot(aes_string(x=x, y=y)) +
      geom_bar(stat = "identity", size=1) +
      xlab(xtit) +
      ylab(ytit) +
      scale_y_continuous(labels = f2si) +
      ggtitle(tit)
  )
}

line_chart(df=data,
           x="Quarter",y="Operations",
           tit="OPERATIONS BY QUARTER",
           xtit="QUARTER", ytit="OPERATIONS")
Run Code Online (Sandbox Code Playgroud)

非常感谢