Hi Christian:
Thanks a lot for your continuous help. This time you got the code right !
That's what I wanted :)
Great job!
Thanks & Regards,
Sauvik
On Sat, Aug 1, 2009 at 10:30 PM, Poersching wrote:
> Hey,
> oh yes, but now I have realy the ultimate solution... ;-)
> Here it comes:
>
> a= c("A
Hey,
oh yes, but now I have realy the ultimate solution... ;-)
Here it comes:
a= c("A1","A2","A3","A4","A5")
b= c("B1","B2","B3")
c= c("C1","C2","C3","C4")
d= c("D1","D2")
e= c("E1","E2","E3","E4","E5","E6","E7","E8")
DataArray_1 = array(c(rnorm(240)),dim=c(length(a),length(b),
length(d),length(
Hi Christian:
Many thank for the code.
But I am afraid that your code still has a problem in terms of providing
correct correlation. For example, if you look at the correlation between
DataArray_1["A2","B1","D1",] and DataArray_2["A2","C1","D1",] after running
your code, you will notice that this
Hey,
i have forgotten to generalize the code so
Correl<-Correl[1:4,,,]
must be
Correl<-Correl[1:length(c),,,]
it's because the comparison levels. I think you don't want the
correlation betweeen A1, B1, D1 and A2, C1, D1 ,
but between A1, B1, D1 and A1, C1, D1 or between A1, B1, D1 and A1, C2, D
Hey,
I think I have a solution for your problem:
Correl<-apply(DataArray_1,1:3, function(d1)
apply(DataArray_2,c(2,1,3), function(d) cor(d1,d))
)
Correl<-Correl[1:4,,,]
dimnames(Correl)[[1]]<-c
Correl<-aperm(Correl,c(2,3,1,4))
This one should work. :-)
Best Regards,
Christian
Sauvik De schrie
Hi there,
Thanks again for your reply. I know for-loop is always a solution to my
problem and I had already coded using for-loop. But the number of levels for
each dimension is large enough in actual problem and hence it was
time-consuming.
So, I was just wondering if there are any other alternati
Sauvik De schrieb:
> Hi:
> Lots of thanks for your valuable time!
>
> But I am not sure how you would like to use the function in this
> situation.
>
> As I had mentioned that the first element of my output array should be
> like:
>
> cor(DataArray_1[dimnames(Correl)[[1]][1],dimnames(Correl)[[2]][1
Hi:
Lots of thanks for your valuable time!
But I am not sure how you would like to use the function in this situation.
As I had mentioned that the first element of my output array should be like:
cor(DataArray_1[dimnames(Correl)[[1]][1],dimnames(Correl)[[2]][1],dimnames(Correl)[[4]][1],],DataArr
Sauvik De schrieb:
> Hi Gabor:
> Many thanks for your prompt reply!
> The code is fine. But I need it in more general form as I had mentioned that
> I need to input any 0 to find its dimension-names.
>
> Actually, I was using "sapply" to calculate correlation and this idea was
> required in the mid
Hi Gabor:
Many thanks for your prompt reply!
The code is fine. But I need it in more general form as I had mentioned that
I need to input any 0 to find its dimension-names.
Actually, I was using "sapply" to calculate correlation and this idea was
required in the middle of correlation calculation.
Try this:
> ix <- c(1, 3, 4, 2)
> mapply("[", dimnames(mydatastructure), ix)
[1] "S1" "T3" "U4" "V2"
On Sat, Jul 25, 2009 at 5:12 PM, Sauvik De wrote:
> Hi:
> How can I extract the dimension-names of a pre-defined element in a
> multidimensional array in R ?
>
> A toy example is provided below:
Hi:
How can I extract the dimension-names of a pre-defined element in a
multidimensional array in R ?
A toy example is provided below:
I have a 4-dimensional array with each dimension having certain length. In
the below example, "mydatastructure" explains the structure of my data.
mydatastructure
12 matches
Mail list logo