我有一个相关矩阵。我尝试在该矩阵上运行cholesky分解函数chol()
,然后通过t()
函数对其进行转置,并将其保存在变量中。
correlation_matrix
元素来自用户,值为:
[,1] [,2] [,3]
[1,] 1.0 0.8 0.2
[2,] 0.8 1.0 0.7
[3,] 0.2 0.7 1.0
我在server.R
中尝试使用以下代码来运行cholesky分解函数并对其进行转置,并且下面是我用来显示chsky_decomp
输出的代码:
#Use Cholesky decomposition
chsky_decomp <- eventReactive(input$corr_matrix_action, {
data.frame(t(chol(correlation_matrix)))
})
#Printing the entered correlation elements for the three varaibles
output$chesky_decomp_matrix <- renderDataTable({
chsky_decomp()
})
但我一直收到错误:cannot coerce type 'closure' to vector of type 'any'
在eventReactive
中尝试了各种格式,例如矩阵,列表等,但没有任何效果。我哪里错了?如何运行这两个函数chol()
&amp;我t()
上的correlation_matrix
并显示了它?
我很有光泽。请帮忙!!