我正在使用带有锁定电源BI的数据库,这不允许我创建新列并且不能轻松地操作数据-我的代码在从R模块运行但在BI中运行时产生了所需的结果我不断收到错误
# The following code to create a dataframe and remove duplicated rows is always executed and acts as a preamble for your script:
# dataset <- data.frame(Equipment Code, Maintenance Downtime Origin Description, Reason Description, Selected Start, Description, After Maintenance Remarks, Start SMU, Start Time, Rank, Is Planned & Contains Service)
# dataset <- unique(dataset)
library(gridExtra)
library(ggplot2)
library(data.table)
library(tidyverse)
Asset=(dataset["Equipment Code"])
Description=(dataset["Description"])
AMR=(dataset["After Maintenance Remarks"])
SMU1=(dataset["Start SMU"])
Task=(dataset["Start Time"])
Planned=(dataset["Is Planned & Contains Service"])
Table1=dataset[with(dataset,order(Asset)),]
Table2=dataset[with(dataset,order(SMU1)),]
Table3=(Table2%>%
mutate(SMU2=shift(SMU1,-1)))
Table4=(Table3%>%
mutate(Delta=SMU2-SMU1))
Table5=(Table4%>%
mutate(EQ=shift(Asset,-1)))
Table6=(Table5%>%
mutate(Check=ifelse(grepl("Y",Planned),"Y","N")))
Table7=(filter(Table6,Planned%in%"Y",Check%in%"Y"))
Table8=(Table7%>%
select(Asset,Task,Delta)
qplot(x=1:5, y=1:5, geom = "blank") +
theme(line = element_blank(), text = element_blank()) +
annotation_custom(grob=tableGrob(Table8))
有关步骤Table4和Table6的错误似乎弹出