mauede at alice.it
2009-Jan-07 00:31 UTC
[R] How-To extract data from a matrix of lists subject to a set of given constraints
My goal is to store the DWT coefficients from a number of time series in such a
way to be able to extract subsets satisfying giben conditions.
I have defined the following 11 matrices whose x-axis represent time intervals
and y-axis represent the number of time series:
MS <- 11 d1.mat <- matrix (data=list(), nrow=TotNumCycles,
ncol=2^(MS-1))
d2.mat <- matrix (data=list(), nrow=TotNumCycles, ncol=2^(MS-3))
d3.mat <- matrix (data=list(), nrow=TotNumCycles, ncol=2^(MS-3))
d4.mat <- matrix (data=list(), nrow=TotNumCycles, ncol=2^(MS-4))
d5.mat <- matrix (data=list(), nrow=TotNumCycles, ncol=2^(MS-5))
d6.mat <- matrix (data=list(), nrow=TotNumCycles, ncol=2^(MS-6))
d7.mat <- matrix (data=list(), nrow=TotNumCycles, ncol=2^(MS-7))
d8.mat <- matrix (data=list(), nrow=TotNumCycles, ncol=2^(MS-8))
d9.mat <- matrix (data=list(), nrow=TotNumCycles, ncol=2^(MS-9))
d10.mat <- matrix (data=list(), nrow=TotNumCycles, ncol=2^(MS-10))
d11.mat <- matrix (data=list(), nrow=TotNumCycles, ncol=2^(MS-11))
Each di.mat (i=1,2,...,11) matrix slot is assigned a DWT coefficient modulus and
the signal and cycle number it belongs to:
coef <- abs (as.numeric (aa.dwt$data[[n]])) #GET DWT COEFFICIENTS
..........................................................
for (k in 1:length(coef)) {
d7.mat [[nCycle ,k]] <- list (data=coef
[k],variable=paste(insig,":",cyc,sep=""))
}
As a consequence d7.mat contains the following:
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] List,2 List,2 List,2 List,2 NULL NULL NULL NULL NULL NULL My
goal is to store the DWT coefficients from a number of time series in such a way
to be able to extract subsets satisfying giben conditions.
I have defined the following 11 matrices whose x-axis represent time intervals
and y-axis represent the number of time series:
MS <- 11 d1.mat <- matrix (data=list(), nrow=TotNumCycles,
ncol=2^(MS-1))
d2.mat <- matrix (data=list(), nrow=TotNumCycles, ncol=2^(MS-3))
d3.mat <- matrix (data=list(), nrow=TotNumCycles, ncol=2^(MS-3))
d4.mat <- matrix (data=list(), nrow=TotNumCycles, ncol=2^(MS-4))
d5.mat <- matrix (data=list(), nrow=TotNumCycles, ncol=2^(MS-5))
d6.mat <- matrix (data=list(), nrow=TotNumCycles, ncol=2^(MS-6))
d7.mat <- matrix (data=list(), nrow=TotNumCycles, ncol=2^(MS-7))
d8.mat <- matrix (data=list(), nrow=TotNumCycles, ncol=2^(MS-8))
d9.mat <- matrix (data=list(), nrow=TotNumCycles, ncol=2^(MS-9))
d10.mat <- matrix (data=list(), nrow=TotNumCycles, ncol=2^(MS-10))
d11.mat <- matrix (data=list(), nrow=TotNumCycles, ncol=2^(MS-11))
Each di.mat (i=1,2,...,11) matrix slot is assigned a DWT coefficient modulus and
the signal and cycle number it belongs to:
coef <- abs (as.numeric (aa.dwt$data[[n]])) #GET DWT COEFFICIENTS
..........................................................
for (k in 1:length(coef)) {
d7.mat [[nCycle ,k]] <- list (data=coef
[k],variable=paste(insig,":",cyc,sep=""))
}
As a consequence d7.mat contains the following:
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] List,2 List,2 List,2 List,2 NULL NULL NULL NULL NULL NULL
[2,] List,2 List,2 List,2 List,2 NULL NULL NULL NULL NULL NULL
[3,] List,2 List,2 List,2 List,2 NULL NULL NULL NULL NULL NULL
[4,] List,2 List,2 List,2 List,2 NULL NULL NULL NULL NULL NULL
[5,] List,2 List,2 List,2 List,2 NULL NULL NULL NULL NULL NULL
[6,] List,2 List,2 List,2 List,2 NULL NULL NULL NULL NULL NULL
[7,] List,2 List,2 List,2 List,2 NULL NULL NULL NULL NULL NULL
[8,] List,2 List,2 List,2 NULL NULL NULL NULL NULL NULL NULL
[9,] List,2 List,2 List,2 List,2 NULL NULL NULL NULL NULL NULL
................................................................................................................> d5.mat[[3,4]]
$data
[1] 0.6290917
$variable
[1] "10146:3"
> d5.mat[[6,4]]
$data
[1] 1.187133
$variable
[1] "10146:6"
> d5.mat[[8,4]]
NULL> d5.mat[[10,4]]
$data
[1] 0.7789786
$variable
[1] "10146:10"
> d5.mat[[50,4]]
$data
[1] 0.8909976
$variable
[1] "10146:50"
How can I extract, for instance, all the data from the i_th column of the
matrix that satisfy a given conditon?
In the case of a matrix A made up of numbers I would write :
which (A [,i] > 0.1) ...?
Thank you in advance for your help.
Maura
tutti i telefonini TIM!
[[alternative HTML version deleted]]
