Dear R users,
I am trying to make this (3 by 10) matrix A
--A----------------------------------------------------
0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0
0 0.5 0.5 0 0 0 0 0 0 0
-------------------------------------------------------
from "mass.func"
--mass.func-------------------------------------------
> mass.func
$`00`
prop
5
1
$`10`
prop
6
1
$`11`
prop
2 3
0.5 0.5
---------------------------------------------------------
which means that
A[1,5] = 1
A[2,6] =1
A[3,2] = A[3,3] = 0.5
otherwise, zero.
Any suggestion will be greatly appreciated.
Regrads,
Kathryn Lord
p.s.
Here is R code.
------------------------------------------------------------------
> dat <- as.data.frame(matrix( c( 2, 1, 1, 3, 1, 1, 6, 1, 0, 5, 0, 0), 4, 3,
byrow=T))
> covar <- apply(dat[,-1],1,paste,collapse='')
> sp.dat <- split(dat,covar)
> y.covar <- lapply(sp.dat, "[",1)
>
> prop <- function(prop) { table(prop)/sum(table(prop)) }
> mass.func <- lapply(y.covar,prop)
> mass.func
$`00`
prop
5
1
$`10`
prop
6
1
$`11`
prop
2 3
0.5 0.5
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.