for this i错误:列x
的长度必须为1或4,而不是2
library(plotly)
library(RColorBrewer)
coul = brewer.pal(4, "BuPu")
Vertrag <- read.table(text =
'"Vert","Start","Ende"
"1","01.07.2017","31.03.2018"
"1","31.03.2018","30.06.2018"
"1","01.07.2018","31.03.2019"
"1","31.03.2019","30.06.2019"',
sep=',',header =T )
Vertrag$Start <- as.Date(Vertrag$Start, format ="%d.%m.%Y")
Vertrag$Ende <- as.Date(Vertrag$Ende, format ="%d.%m.%Y")
p <- plot_ly()
for(i in 1:(nrow(Vertrag))){
p <- add_trace(p,
x = c(Vertrag$Start[i],Vertrag$Start[i] + difftime(Vertrag$Ende[i],Vertrag$Start[i], units = "days")),
y = c(Vertrag$Vert),
mode = "lines",
line = list(color = colorRampPalette(coul)(10),width = 20))
}
p
但是当“Vertrag”只有两行时,它可以工作。
知道为什么和什么错了?
谢谢
奥拉夫
答案 0 :(得分:1)
将public List<MyObject> Items { get; set; }
public string Filter
{
get { return filter; }
set
{
filter = value;
// Apply filter to list of Items here...
}
}
函数中的y轴从add_trace()
更改为y = c(Vertrag$Vert)
对我有用。
但我不确定这是你想要的情节。