y***6 发帖数: 46 | 1 Hi all,
I got some new questions about R. Any help is appreciated!
First Question:
If I have the following three row/column vectors:
A=[0, 0 , 0, 0 ,0];
B=[0.1,0.2,0.3,.5,0.6];
C=[1,1,1,1,1];
I want to verify if elments in B are within the corresponding
boundary as defined in vector A and vector C (component-wise), for example,
1st element: 0<0.1<1--> TRUE
2nd element: 0 | D******n 发帖数: 2836 | 2 1)(B>A)&(C>B)
2)(x[,,1]+x[,,2])/2
【在 y***6 的大作中提到】![](/moin_static193/solenoid/img/up.png) : Hi all, : I got some new questions about R. Any help is appreciated! : First Question: : If I have the following three row/column vectors: : A=[0, 0 , 0, 0 ,0]; : B=[0.1,0.2,0.3,.5,0.6]; : C=[1,1,1,1,1]; : I want to verify if elments in B are within the corresponding : boundary as defined in vector A and vector C (component-wise), for example, : 1st element: 0<0.1<1--> TRUE
| y***6 发帖数: 46 | 3 What if A is 2-by-2-100000, it's no convenient to do
(A[,,1]+...+A[,,100000])/2
which actually calls for a loop. Can we do this without loop? Thanks Da
Shagen for answer to my first question! | D******n 发帖数: 2836 | 4 apply(A,c(1,2),sum)
【在 y***6 的大作中提到】![](/moin_static193/solenoid/img/up.png) : What if A is 2-by-2-100000, it's no convenient to do : (A[,,1]+...+A[,,100000])/2 : which actually calls for a loop. Can we do this without loop? Thanks Da : Shagen for answer to my first question!
|
|