0
我写的作品时,没有闪亮的自定义函数内,我尝试我的闪亮的应用程序,它返回一个错误闪亮:自定义函数不发亮应用
Error in rowMeans(data[, c:x]) :
'x' must be an array of at least two dimensions
中使用它的工作,但只要所以它显然与rowMeans调用有关,但是我将一个数据框传递给它,并且我已经改变了将数据框强制到一个数组的功能,但这没有奏效。我也试着把这个函数放在服务器文件顶部的几个地方,在被动表达式中,还有一个'helpers'文件,如其中一个例子所示,这是我希望它保留下来的地方。
我已经创造了什么是希望,再现下面的误差最小的例子。感谢您的任何帮助和建议!
shinyApp(
ui = fluidPage(
sidebarLayout(
sidebarPanel(selectInput('block','Choose Block',
c('1' = 1,
'2' = 2,
'3' = 3,
'4' = 4,
'6' = 6,
'8' = 8,
'12' = 12))),
mainPanel(tableOutput("test"))
)
),
server = function(input, output) {
DF<-data.frame(replicate(24,sample(0:10,13,rep=TRUE)))
block<- function(data, blocks){
data<-array(data)
month<-data.frame(seq(0,12))
testy<-data.frame(month)
y<-1
b<-blocks
a<-0
while(y<24){
a <- a + 1;
y <- a * b;
c <- y + 1 - b;
d <- "block";
e <- as.character(a);
f <- paste(d,e, sep = '');
z <- data.frame(rowMeans(data[,c:y]));
colnames(z)[1]<-f
testy <- cbind(testy,z)
}
return (testy)
}
output$test <- renderTable(
block(DF,as.numeric(input$block))
)
}
)
调查如果c:x长度为1,例如3:3什么的。 – joran
我明白了。谢谢你,多么愚蠢的错误。 –
不要重新分配'c',它只是要求麻烦 – hedgedandlevered