Julia函数有什么问题?

时间:2019-10-15 02:46:36

标签: julia

我正在尝试在Julia中创建稀疏矩阵,但目前遇到了这个问题:

ERROR: MethodError: no method matching createA(::DataFrame)

我在做什么错?我如何解决它? 这是代码:

import SparseMatrixDicts
import DataFrames  
import CSV
function createA()

t1 = argmin(argmax(keg[Array(keg[:dad]  .> 0) .& Array(argmax(keg[:mum] .> 0))]))
t2 = argmax(keg[:ID])
A = SparseMatrixDicts(t2, t2)
diagm(A) = 2-0.5^(keg[:GEN] -1)

  for t in t1:t2
  A[t,t]= sum(c(A[t,t], 0.5^(keg[t,"GEN"])*A[keg[t,"dad"],keg[t,"mum"]]))

    vec = 1:(t-1)


    A[t, vec]= 0.5 * sum(c(A[vec,keg[t,"dad"]],A[vec,keg[t,"mum"]]))
    A[vec,t]= A[t,vec]


  return (A)
  end
end 

keg = DataFrame(ID = [1,2,3,4,6,5,7],
                dad = [0,0,1,1,1,3,5],
                mum = [0,0,0,2,4,4,6],
                GEN = [1,1,2,2,3,3,4]
                )

wish = createA(keg)

1 个答案:

答案 0 :(得分:3)

您已经定义了一个函数createA,该函数不带任何参数,然后用一个参数调用它,这当然是行不通的。尝试将函数声明为function createA(keg)