m***@163.com
2015-07-31 04:44:30 UTC
Hello, I do not know how to change "list()" "c(sib1,sib2)" and
"a[[v]][inhe[[v]]==par] <-
par.al[[par]][inhe[[v]]==par]" in R to julia code.
It is error:
ERROR: BoundsError()
in getindex at array.jl:246 (repeats 2 times)
#####R code
n.ped <- nrow(sib1$pat)
n.mark <- ncol(sib1$pat)
n.al <- length(f)
par.al <- list()
for(par in 1:4) par.al[[par]] <-
matrix(sample(1:n.al,n.ped*n.mark,
replace=TRUE,prob=f),n.ped,n.mark)
a <- inhe <- c(sib1,sib2)
for (v in 1:4) for (par in 1:4)
a[[v]][inhe[[v]]==par] <-
par.al[[par]][inhe[[v]]==par]
###julia code
nped=size(sib1,1)
nmark=size(sib1,2)
nal=size(f,2)
paral=Dict()
for (par=1:4)
paral[[par]]=reshape(wsample([1:nal],vec(f),nped*4*nmark),nped*4,nmark)
end
#a=inhe=hcat(sib1,sib2,sib3,sib4)
a=inhe=(Sib1,Sib2,Sib3,Sib4)
a=inhe=convert(DataFrame,a)
println("mbjok")
for (v=1:4) for(par=1:4)
println(v,par)
if inhe[[v]]==par
a[v,inhe[v]]=paral[par,inhe[v]]
end
end end
"a[[v]][inhe[[v]]==par] <-
par.al[[par]][inhe[[v]]==par]" in R to julia code.
It is error:
ERROR: BoundsError()
in getindex at array.jl:246 (repeats 2 times)
#####R code
n.ped <- nrow(sib1$pat)
n.mark <- ncol(sib1$pat)
n.al <- length(f)
par.al <- list()
for(par in 1:4) par.al[[par]] <-
matrix(sample(1:n.al,n.ped*n.mark,
replace=TRUE,prob=f),n.ped,n.mark)
a <- inhe <- c(sib1,sib2)
for (v in 1:4) for (par in 1:4)
a[[v]][inhe[[v]]==par] <-
par.al[[par]][inhe[[v]]==par]
###julia code
nped=size(sib1,1)
nmark=size(sib1,2)
nal=size(f,2)
paral=Dict()
for (par=1:4)
paral[[par]]=reshape(wsample([1:nal],vec(f),nped*4*nmark),nped*4,nmark)
end
#a=inhe=hcat(sib1,sib2,sib3,sib4)
a=inhe=(Sib1,Sib2,Sib3,Sib4)
a=inhe=convert(DataFrame,a)
println("mbjok")
for (v=1:4) for(par=1:4)
println(v,par)
if inhe[[v]]==par
a[v,inhe[v]]=paral[par,inhe[v]]
end
end end