我正在尝试格式化ggplot图的y轴标签的成本和收入(以千为单位)和印象数(以百万计)数据.
我的情节从31天前运行到"昨天",并使用该期间的最小值和最大值作为ylim(c(min,max))选项.仅显示成本示例,
library(ggplot2)
library(TTR)
set.seed(1984)
#make series
start <- as.Date('2016-01-01')
end <- Sys.Date()
days <- as.numeric(end - start)
#make cost and moving averages
cost <- rnorm(days, mean = 45400, sd = 11640)
date <- seq.Date(from = start, to = end - 1, by = 'day')
cost_7 <- SMA(cost, 7)
cost_30 <- SMA(cost, 30)
df <- data.frame(Date = date, Cost = cost, Cost_7 = cost_7, Cost_30 = cost_30)
# set parameters for window
left <- end - 31
right …Run Code Online (Sandbox Code Playgroud)