[R] negative extents to matrix

2013-05-16 Thread Muhammad Azam
resMatp - cbind(matp,LorRnode,unit,misc.unit,deviance,class); print(resMatp)   
 
eTrain - round(mean(eTraining)/avelength*100,digits=2); eTest - 
round(tec2NF/nrow(ww)*100,digits=2); dev.sum - sum(deviance);
 print(cbind(eTrain,eTest,dev.sum))
 }
  CTPrundUnprund(iris,150,1,4,5,1,3,10,10) 




best regards

Muhammad Azam  
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


[R] request: maximum depth reached problem

2009-04-09 Thread Muhammad Azam
Dear R community
Hope all of you are fine. I have a question regarding the an error message. 
Actually, I am trying to generate classification trees using tree package. It 
works well but for some datasets e.g., wine, yeast, boston housing etc. it 
gives an error message.

Error in tree(V14 ~ ., data = training.data, method = 
c(recursive.partitioning),  : 
maximum depth reached

The structure of getting output is given below:

iris.tr = tree(Species ~., data=training.data, 
method=c(recursive.partitioning), split = c(gini), 
control=tree.control(nobs = 150, minsize = 5, mincut = 2))

Any suggestion will be appreciated to handle the above problem. Thanks and
  

best regards

Muhammad Azam 


  
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


[R] request: cost complexity parameter k

2009-04-02 Thread Muhammad Azam
Dear R community
I
have a question regarding the value of cost complexity parameter k
used in tree package for pruning purpose. In the example below i used k=0. 
But if i take the value k=NULL, then it will not plot the resultant tree. Any 
help in finding the
optimum value of k is requested. Please give some suggestion in this
regard. Thanks  

library(tree)
ds=iris; iris=transform(iris, Species = factor(Species, labels = letters[1:3]))
miris
- tree(Species ~ ., data = iris, control=tree.control(nobs = 150,
minsize = 5, mincut = 2)); iris.prun=prune.tree(miris,
method=c(misclass), best = NULL, k=0); iris.prun; summary(iris.prun);
plot(iris.prun)


 
best regards

Muhammad Azam 


  
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


[R] Request: Optimum value of cost complexity parameter k in tree package

2009-04-01 Thread Muhammad Azam
Dear R community
I have a question regarding the value of cost complexity parameter k used in 
tree package for pruning purpose. Any help in finding the optimum value of 
k is requested. Please give some suggestion in this regard. In the example 
below i used k=0 but i don't know why? But if i use k=NULL, then it will not 
plot the resultant tree.  

library(tree)
ds=iris; iris=transform(iris, Species = factor(Species, labels = letters[1:3]))
miris - tree(Species ~ ., data = iris, control=tree.control(nobs = 150, 
minsize = 5, mincut = 2)); iris.prun=prune.tree(miris, method=c(misclass), 
best = NULL, k=0); iris.prun; summary(iris.prun); plot(iris.prun)


 
best regards

Muhammad Azam 



  
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


[R] loop problem

2009-03-26 Thread Muhammad Azam
Dear R members
I have a problem regarding storing the lists.
Let 
L=number of distinct values of any predictor (say L=5)
P=number of predictors (say P=20)

g1 - c()
for(i in 1:P){
if(L  1){
  for(j in 1:(L-1)){
g - 
g1[j] - g
   }
}
g2[]=sort.list(g1)
}

Now the question is: What should we use inside brackets of g2[], whether 
i or some thing else? If L is not greater than 1 then there will be a NULL 
for g2. We don't want to store it in g2, so how can we handle this problem. 
Looking forward for some help. Thanks and 

 
best regards

Muhammad Azam 



  
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


[R] request: how to assign alphabets to integer values

2008-12-01 Thread Muhammad Azam
Dear R community
I am trying to assign alphabets to integer values 1, 2, 3 etc. in y given 
below. Can any body suggest some simple way to do the same job?

ds=iris; dl=nrow(ds)
c1=ds[,1]; c2=ds[,2]; c3=ds[,3]; c4=ds[,4]; c5=ds[,5]; 
iris=cbind(c1,c2,c3,c4,c5)
y=iris[,5]
y1=which(y==1); y[y1] - c(a); y2=which(y==2); y[y2] - c(b); 
y3=which(y==3); y[y3] - c(c); 
iris=cbind(c1,c2,c3,c4,y)

Thnks and best regards
M. Azam


  
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


Re: [R] request: how to assign alphabets to integer values

2008-12-01 Thread Muhammad Azam
Dear Gabor Grothendieck 
Thanks a lot for the help.

M. Azam



From: Gabor Grothendieck [EMAIL PROTECTED]

Cc: R-help request [EMAIL PROTECTED]; R Help r-help@r-project.org
Sent: Monday, December 1, 2008 12:46:06 PM
Subject: Re: [R] request: how to assign alphabets to integer values

Try:

transform(iris, Species = factor(Species, labels = letters[1:3]))


 Dear R community
 I am trying to assign alphabets to integer values 1, 2, 3 etc. in y given 
 below. Can any body suggest some simple way to do the same job?

 ds=iris; dl=nrow(ds)
 c1=ds[,1]; c2=ds[,2]; c3=ds[,3]; c4=ds[,4]; c5=ds[,5]; 
 iris=cbind(c1,c2,c3,c4,c5)
 y=iris[,5]
 y1=which(y==1); y[y1] - c(a); y2=which(y==2); y[y2] - c(b); 
 y3=which(y==3); y[y3] - c(c);
 iris=cbind(c1,c2,c3,c4,y)

 Thnks and best regards
 M. Azam



        [[alternative HTML version deleted]]


 __
 R-help@r-project.org 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.





  
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


Re: [R] request: How to combine three matrices in the desired form

2008-10-30 Thread Muhammad Azam
Dear Jim
Thanks a lot for such a nice solution. 
best regards
M.Azam





From: Jim Lemon [EMAIL PROTECTED]

Cc: R Help r-help@r-project.org
Sent: Thursday, October 30, 2008 10:06:57 AM
Subject: Re: [R] request: How to combine three matrices in the desired form

Hi Muhammad,
Try this:
cbind(matrix(paste(var,(,val,),sep=),nrow=4),as.character(nod))

Jim


  
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


Re: [R] Odp: Request: Most repeated sequence considering combinations at each row

2008-10-27 Thread Muhammad Azam
Dear Petr
Thanks for the response. Hope it will now help me to proceed. 
best regards
M.Azam



From: Petr PIKAL [EMAIL PROTECTED]

Cc: R Help r-help@r-project.org; [EMAIL PROTECTED]
Sent: Monday, October 27, 2008 8:43:27 AM
Subject: Odp: [R] Request: Most repeated sequence considering combinations at 
each row

Hi

not sure if this is what you want. It does not do fuzzy matching but make 
a exact evaluation equal row sums of arrays.

rle(do.call(c,lapply(lapply(l, rowSums), function(x) paste(x, 
collapse=

Maybe something similar can be done without conversion to character.

Regards
Petr

[EMAIL PROTECTED] napsal dne 24.10.2008 12:34:15:

 Dear friends
 Hope you all are fine. Suppose we have a list of arrays.
 a1=c(4,4,4,4,0,4,4,4,0,3,3,0,0,0,0,0);  a1=array(a1,dim=c(4,4)); 
a2=c(4,4,4,
 4,0,4,4,4,0,3,3,0,0,0,0,0);  a2=array(a2,dim=c(4,4)); 
 a3=c(4,4,4,4,0,3,3,4,0,4,4,0,0,0,0,0); a3=array(a3,dim=c(4,4)); 
a4=c(4,4,4,4,
 4,0,3,3,3,3,0,4,4,4,0,0,0,0,0,0); a4=array(a4,dim=c(5,4)); 
a5=c(4,4,4,4,4,0,4,
 4,4,4,0,3,3,3,0,0,1,1,0,0); a5=array(a5,dim=c(5,4)); 
a6=c(4,4,4,4,4,0,1,1,1,1,
 0,4,4,4,0,0,3,3,0,0); a6=array(a6,dim=c(5,4)); 
a7=c(1,1,1,1,1,0,4,4,4,4,0,3,3,
 3,0,0,4,4,0,0); a7=array(a7,dim=c(5,4)); 
a8=c(4,4,4,4,4,0,3,3,3,3,0,1,1,1,0,0,
 4,4,0,0); a8=array(a8,dim=c(5,4));
 l=list(a1,a2,a3,a4,a5,a6,a7,a8); 
 
 x - sapply(1:length(l), function(x) {
   sum(sapply(l, function(y) {
 if ( nrow(l[[x]]) != nrow(y) | ncol(l[[x]]) != ncol(y) ) FALSE
 else sum(y != l[[x]]) == 0
   }))
 } ); l; x
 
 Using the above function, we are able to get frequency of each most 
repeated 
 similar components of the list. For example, [[1]] and [[2]] are most 
repeated
 similar out of all. But if we consider the combinations at each row of 
each 
 array. Then [[3]] will be included with [[1]] and [[2]]. Also [[5]], 
[[6]] and
 [[8]] will be similar. How can we modify the above function to get the 
desired
 most repeated sequence in this case? Any help in this regard is needed. 
 
 best regards
 M.Azam 
 
 
 
 
[[alternative HTML version deleted]]
 
 __
 R-help@r-project.org 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.


  
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


[R] Request: Most repeated sequence considering combinations at each row

2008-10-24 Thread Muhammad Azam
Dear friends
Hope you all are fine. Suppose we have a list of arrays.
a1=c(4,4,4,4,0,4,4,4,0,3,3,0,0,0,0,0);  a1=array(a1,dim=c(4,4));  
a2=c(4,4,4,4,0,4,4,4,0,3,3,0,0,0,0,0);  a2=array(a2,dim=c(4,4));  
a3=c(4,4,4,4,0,3,3,4,0,4,4,0,0,0,0,0); a3=array(a3,dim=c(4,4)); 
a4=c(4,4,4,4,4,0,3,3,3,3,0,4,4,4,0,0,0,0,0,0); a4=array(a4,dim=c(5,4)); 
a5=c(4,4,4,4,4,0,4,4,4,4,0,3,3,3,0,0,1,1,0,0); a5=array(a5,dim=c(5,4)); 
a6=c(4,4,4,4,4,0,1,1,1,1,0,4,4,4,0,0,3,3,0,0); a6=array(a6,dim=c(5,4)); 
a7=c(1,1,1,1,1,0,4,4,4,4,0,3,3,3,0,0,4,4,0,0); a7=array(a7,dim=c(5,4)); 
a8=c(4,4,4,4,4,0,3,3,3,3,0,1,1,1,0,0,4,4,0,0); a8=array(a8,dim=c(5,4));
l=list(a1,a2,a3,a4,a5,a6,a7,a8); 

x - sapply(1:length(l), function(x) {
  sum(sapply(l, function(y) {
if ( nrow(l[[x]]) != nrow(y) | ncol(l[[x]]) != ncol(y) ) FALSE
else sum(y != l[[x]]) == 0
  }))
} ); l; x

Using the above function, we are able to get frequency of each most repeated 
similar components of the list. For example, [[1]] and [[2]] are most repeated 
similar out of all. But if we consider the combinations at each row of each 
array. Then [[3]] will be included with [[1]] and [[2]]. Also [[5]], [[6]] and 
[[8]] will be similar. How can we modify the above function to get the desired 
most repeated sequence in this case? Any help in this regard is needed. 

best regards
M.Azam   



  
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


[R] Request: How to draw a tree

2008-10-16 Thread Muhammad Azam
Dear friends
As a result I get an array containing certain no of rows and columns. In the 
resultant array first row represents first node of a tree starting from left 
side, second row represents second node of that tree and so on. In the example 
below, the resultant tree contains 6 nodes.  We get the first node on L.H.S by 
splitting top node using variable 10, node 2 by taking start from the R.H.S 
node then splitting it using variables 7 and 11 respectively [ Note: 0's are 
not the variables ]. All the nodes are connected on this way to get the whole 
tree.  We can easily draw it manually. Now the question is, is it possible to 
draw it using R. Any help in this regard is needed. Thanks
 [,1] [,2] [,3] [,4]
[1,]   10000
[2,]   107   110
[3,]   107   110
[4,]   107   13   11
[5,]   107   13   11
[6,]   107   130

regards
M. Azam



  
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


Re: [R] request: How can we ignore a component of list having no element

2008-10-15 Thread Muhammad Azam
Dear Mahbub
Thanks a lot for the help.



- Original Message 
From: Mahbub Latif [EMAIL PROTECTED]
To: Muhammad Azam [EMAIL PROTECTED]
Sent: Wednesday, October 15, 2008 12:30:13 PM
Subject: Re: [R] request: How can we ignore a component of list having no 
element


try this,

junk - sapply(x,function(i) !is.null(i))
y - x[junk]



On Wed, Oct 15, 2008 at 11:23 AM, Muhammad Azam [EMAIL PROTECTED] wrote:

Dear friends
There is a list of arrays comprising different no of rows and columns even 
sometimes NULL, such as [[2]] given below. How can we ignore [[2]] or others 
like this in the complete list. Any help in this regard is needed. Thanks

[[1]]
  [,1] [,2]
[1,]31
[2,]31
[3,]31

[[2]]
NULL

[[3]]
   [,1] [,2] [,3] [,4] [,5] [,6] [,7]
 [1,]3100000
 [2,]3100000
 [3,]3100000
 [4,]3131321
 [5,]3131321
 [6,]3131320

[[4]]
  [,1] [,2] [,3] [,4]
[1,]3000
[2,]3133
[3,]3133
[4,]3130

OR
x1=c(1,2,3); x2=c(1,2,3,4,6); x3=c(); x=list(x1,x2,x3)

M.Azam



   [[alternative HTML version deleted]]

__
R-help@r-project.org 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.



-- 
A.H.M. Mahbub Latif
Assistant Professor
Applied Statistics
Institute of Statistical Research and Training
University of Dhaka, Dhaka 1000, Bangladesh
web : http://www.isrt.ac.bd/mlatif



  
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


[R] request: How to ignore columns having zero sums

2008-10-14 Thread Muhammad Azam
Dear friends
I have an array consist of r-rows and c-columns e.g.
x=c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,0,0,0,0,0,0,0,0); 
x1=array(x, dim=c(4,6))
output is
 x1
 [,1] [,2] [,3] [,4] [,5] [,6]
[1,]123400
[2,]123400
[3,]123400
[4,]123400
How can i ignore columns having zero sums? Help in this regard is needed. Thanks

 
M.Azam


  
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


Re: [R] request: How to ignore columns having zero sums

2008-10-14 Thread Muhammad Azam
Dear Dimitris 
Thanks a lot. 




- Original Message 
From: Dimitris Rizopoulos [EMAIL PROTECTED]
To: Muhammad Azam [EMAIL PROTECTED]
Cc: R Help r-help@r-project.org
Sent: Tuesday, October 14, 2008 10:10:54 AM
Subject: Re: [R] request: How to ignore columns having zero sums

try this:

x - c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,0,0,0,0,0,0,0,0);
x1 - array(x, dim=c(4,6))

ind - colSums(x1) != 0
x1[, ind]


I hope it helps.

Best,
Dimitris


Muhammad Azam wrote:
 Dear friends
 I have an array consist of r-rows and c-columns e.g.
 x=c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,0,0,0,0,0,0,0,0); 
 x1=array(x, dim=c(4,6))
 output is
 x1
  [,1] [,2] [,3] [,4] [,5] [,6]
 [1,]123400
 [2,]123400
 [3,]123400
 [4,]123400
 How can i ignore columns having zero sums? Help in this regard is needed. 
 Thanks
 
  
 M.Azam
 
 
  
 [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org 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.
 

-- 
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014


  
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


Re: [R] request: How to ignore columns having zero sums

2008-10-14 Thread Muhammad Azam
Dear Jorge
Thanks a lot.



- Original Message 
From: Jorge Ivan Velez [EMAIL PROTECTED]
To: Muhammad Azam [EMAIL PROTECTED]
Cc: R mailing list r-help@r-project.org
Sent: Tuesday, October 14, 2008 1:52:15 PM
Subject: Re: [R] request: How to ignore columns having zero sums



Dear Muhammad,

Try also

x - c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,0,0,0,0,0,0,0,0);
x1 - array(x, dim=c(4,6))
x1[,apply(x1,2,function(x) !all(x==0))]

HTH,

Jorge


On Tue, Oct 14, 2008 at 4:02 AM, Muhammad Azam [EMAIL PROTECTED] wrote:

Dear friends
I have an array consist of r-rows and c-columns e.g.
x=c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,0,0,0,0,0,0,0,0);
x1=array(x, dim=c(4,6))
output is
 x1
[,1] [,2] [,3] [,4] [,5] [,6]
[1,]123400
[2,]123400
[3,]123400
[4,]123400
How can i ignore columns having zero sums? Help in this regard is needed. Thanks


M.Azam



   [[alternative HTML version deleted]]

__
R-help@r-project.org 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.


  
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


Re: [R] request: most repeated component of a list

2008-09-11 Thread Muhammad Azam
May be i could not explain properly. Actually there are components of
list i.e. [[1]] to [[500]]. Each component containing r-rows (may be
different for each [[ k ]] and c-columns same for all). I have to
compare all the [[ k ]] components of that list and found the one
appearing maximum no of times. e.g. from three components [[1]] to
[[3]] given below. The most repeated is 

 [,1] [,2] [,3] [,4] [,5]
 [1,]40000
 [2,]43400
 [3,]43400
 [4,]43000Please help to find it. Thanks and 

best regards
Muhammad Azam


- Original Message 
From: jim holtman [EMAIL PROTECTED]
To: Muhammad Azam [EMAIL PROTECTED]
Cc: R-help request [EMAIL PROTECTED]; R Help r-help@r-project.org
Sent: Wednesday, September 10, 2008 5:59:28 PM
Subject: Re: [R] request: most repeated component of a list

If want you want is the summary from all of them, then 'rbind' the
data together into one matrix and analyze it:

totalMat - do.call(rbind, listOfMatrices)

On Wed, Sep 10, 2008 at 11:49 AM, Muhammad Azam [EMAIL PROTECTED] wrote:
 Dear R community

I have stored the results of arrays in a list consist of J-components
(say 200 components). Each component containing same no of columns but
may be different no of rows. e.g
 [[1]]
 [,1] [,2] [,3] [,4] [,5]
 [1,]40000
 [2,]43400
 [3,]43400
 [4,]43000

 [[2]]
 [,1] [,2] [,3] [,4] [,5]
 [1,]40000
 [2,]43400
 [3,]43400
 [4,]43000

 [[3]]
 [,1] [,2] [,3] [,4] [,5]
 [1,]40000
 [2,]44100
 [3,]44100
 [4,]44000
 [5,]44000


For 200 components i want to make a frequency table. How can i make a
frequency table of these components or the most repeated component out
of all? Any help in this regard will be appreciated.


 Muhammad Azam



[[alternative HTML version deleted]]

 __
 R-help@r-project.org 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.




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?


  
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


Re: [R] request: most repeated component of a list

2008-09-11 Thread Muhammad Azam
Thanks for the effort but still we are far from the desired result. May be this 
example will help you to understand the situation. Example
a1=c(1:12);   a1=array(a1,dim=c(3,4));   a2=c(1:12);  a2=array(a2,dim=c(3,4));  
a3=c(1:16)
a3=array(a3,dim=c(4,4));  
a=list(a1,a2,a3); 
a
[[1]]
 [,1] [,2] [,3] [,4]
[1,]147   10
[2,]258   11
[3,]369   12

[[2]]
 [,1] [,2] [,3] [,4]
[1,]147   10
[2,]258   11
[3,]369   12

[[3]]
 [,1] [,2] [,3] [,4]
[1,]159   13
[2,]26   10   14
[3,]37   11   15
[4,]48   12   16

Here [[1]] and [[2]] are same out of three (internal values wise). The whole 
array [[1]] or [[2]] is in majority. So i want to get the whole array or 
component of list which is in majority. The result should be like this
 [,1] [,2] [,3] [,4]
[1,]147   10
[2,]258   11
[3,]369   12

Hope it is much more clear as before. 

best regards
Muhammad Azam


- Original Message 
From: Adam D. I. Kramer [EMAIL PROTECTED]
To: Muhammad Azam [EMAIL PROTECTED]
Cc: R Help r-help@r-project.org
Sent: Thursday, September 11, 2008 9:53:40 AM
Subject: Re: [R] request: most repeated component of a list

That is indeed different from what I thought the first time.

x - sapply(1:length(l), function(x) {
   sum(sapply(l, function(y) {
 if ( nrow(l[[x]]) != nrow(y) | ncol(l[[x]]) != ncol(y) ) FALSE
 else sum(y != l[[x]]) == 0
   }))
} )

names(x) - names(l)

Then, x has the same names as l, and x[i] is the number of matches that
l[[i]] has...so you want the index or indices of max(x).

--Adam

On Thu, 11 Sep 2008, Muhammad Azam wrote:

 May be i could not explain properly. Actually there are components of
 list i.e. [[1]] to [[500]]. Each component containing r-rows (may be
 different for each [[ k ]] and c-columns same for all). I have to
 compare all the [[ k ]] components of that list and found the one
 appearing maximum no of times. e.g. from three components [[1]] to
 [[3]] given below. The most repeated is

 [,1] [,2] [,3] [,4] [,5]
 [1,]40000
 [2,]43400
 [3,]43400
 [4,]43000Please help to find it. Thanks and

 best regards
 Muhammad Azam


 - Original Message 
 From: jim holtman [EMAIL PROTECTED]
 To: Muhammad Azam [EMAIL PROTECTED]
 Cc: R-help request [EMAIL PROTECTED]; R Help r-help@r-project.org
 Sent: Wednesday, September 10, 2008 5:59:28 PM
 Subject: Re: [R] request: most repeated component of a list

 If want you want is the summary from all of them, then 'rbind' the
 data together into one matrix and analyze it:

 totalMat - do.call(rbind, listOfMatrices)

 On Wed, Sep 10, 2008 at 11:49 AM, Muhammad Azam [EMAIL PROTECTED] wrote:
 Dear R community

 I have stored the results of arrays in a list consist of J-components
 (say 200 components). Each component containing same no of columns but
 may be different no of rows. e.g
 [[1]]
 [,1] [,2] [,3] [,4] [,5]
 [1,]40000
 [2,]43400
 [3,]43400
 [4,]43000

 [[2]]
 [,1] [,2] [,3] [,4] [,5]
 [1,]40000
 [2,]43400
 [3,]43400
 [4,]43000

 [[3]]
 [,1] [,2] [,3] [,4] [,5]
 [1,]40000
 [2,]44100
 [3,]44100
 [4,]44000
 [5,]44000


 For 200 components i want to make a frequency table. How can i make a
 frequency table of these components or the most repeated component out
 of all? Any help in this regard will be appreciated.


 Muhammad Azam



[[alternative HTML version deleted]]

 __
 R-help@r-project.org 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.




 -- 
 Jim Holtman
 Cincinnati, OH
 +1 513 646 9390

 What is the problem that you are trying to solve?



 [[alternative HTML version deleted]]

 __
 R-help@r-project.org 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.




  
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


Re: [R] request: most repeated component of a list

2008-09-11 Thread Muhammad Azam
Thanks a lot for this effort.




- Original Message 
From: Dimitris Rizopoulos [EMAIL PROTECTED]
To: Muhammad Azam [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]; R Help r-help@r-project.org
Sent: Thursday, September 11, 2008 10:52:16 AM
Subject: Re: [R] request: most repeated component of a list

try the following:

ff - function (x) {
   do.call(paste, c(as.data.frame(x), sep = \r, collapse = ))
}
pats - sapply(a, ff)
ind - which.max(table(pats))
a[[ind]]


I hope it helps.

Best,
Dimitris


 Thanks for the effort but still we are far from the desired result. May be
 this example will help you to understand the situation. Example
 a1=c(1:12);   a1=array(a1,dim=c(3,4));   a2=c(1:12);
 a2=array(a2,dim=c(3,4));  a3=c(1:16)
 a3=array(a3,dim=c(4,4));
 a=list(a1,a2,a3);
 a
 [[1]]
  [,1] [,2] [,3] [,4]
 [1,]147   10
 [2,]258   11
 [3,]369   12

 [[2]]
  [,1] [,2] [,3] [,4]
 [1,]147   10
 [2,]258   11
 [3,]369   12

 [[3]]
  [,1] [,2] [,3] [,4]
 [1,]159   13
 [2,]26   10   14
 [3,]37   11   15
 [4,]48   12   16

 Here [[1]] and [[2]] are same out of three (internal values wise). The
 whole array [[1]] or [[2]] is in majority. So i want to get the whole
 array or component of list which is in majority. The result should be like
 this
  [,1] [,2] [,3] [,4]
 [1,]147   10
 [2,]258   11
 [3,]369   12

 Hope it is much more clear as before.

 best regards
 Muhammad Azam


 - Original Message 
 From: Adam D. I. Kramer [EMAIL PROTECTED]
 To: Muhammad Azam [EMAIL PROTECTED]
 Cc: R Help r-help@r-project.org
 Sent: Thursday, September 11, 2008 9:53:40 AM
 Subject: Re: [R] request: most repeated component of a list

 That is indeed different from what I thought the first time.

 x - sapply(1:length(l), function(x) {
sum(sapply(l, function(y) {
  if ( nrow(l[[x]]) != nrow(y) | ncol(l[[x]]) != ncol(y) ) FALSE
  else sum(y != l[[x]]) == 0
}))
 } )

 names(x) - names(l)

 Then, x has the same names as l, and x[i] is the number of matches that
 l[[i]] has...so you want the index or indices of max(x).

 --Adam

 On Thu, 11 Sep 2008, Muhammad Azam wrote:

 May be i could not explain properly. Actually there are components of
 list i.e. [[1]] to [[500]]. Each component containing r-rows (may be
 different for each [[ k ]] and c-columns same for all). I have to
 compare all the [[ k ]] components of that list and found the one
 appearing maximum no of times. e.g. from three components [[1]] to
 [[3]] given below. The most repeated is

 [,1] [,2] [,3] [,4] [,5]
 [1,]40000
 [2,]43400
 [3,]43400
 [4,]43000Please help to find it. Thanks and

 best regards
 Muhammad Azam


 - Original Message 
 From: jim holtman [EMAIL PROTECTED]
 To: Muhammad Azam [EMAIL PROTECTED]
 Cc: R-help request [EMAIL PROTECTED]; R Help
 r-help@r-project.org
 Sent: Wednesday, September 10, 2008 5:59:28 PM
 Subject: Re: [R] request: most repeated component of a list

 If want you want is the summary from all of them, then 'rbind' the
 data together into one matrix and analyze it:

 totalMat - do.call(rbind, listOfMatrices)

 On Wed, Sep 10, 2008 at 11:49 AM, Muhammad Azam [EMAIL PROTECTED]
 wrote:
 Dear R community

 I have stored the results of arrays in a list consist of J-components
 (say 200 components). Each component containing same no of columns but
 may be different no of rows. e.g
 [[1]]
 [,1] [,2] [,3] [,4] [,5]
 [1,]40000
 [2,]43400
 [3,]43400
 [4,]43000

 [[2]]
 [,1] [,2] [,3] [,4] [,5]
 [1,]40000
 [2,]43400
 [3,]43400
 [4,]43000

 [[3]]
 [,1] [,2] [,3] [,4] [,5]
 [1,]40000
 [2,]44100
 [3,]44100
 [4,]44000
 [5,]44000


 For 200 components i want to make a frequency table. How can i make a
 frequency table of these components or the most repeated component out
 of all? Any help in this regard will be appreciated.


 Muhammad Azam



[[alternative HTML version deleted]]

 __
 R-help@r-project.org 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.




 --
 Jim Holtman
 Cincinnati, OH
 +1 513 646 9390

 What is the problem that you are trying to solve?



 [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html

[R] request: table of sequences

2008-09-10 Thread Muhammad Azam
Dear R community
The following code gives me the most repeated sequence of values. i.e.
x=c(1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,2,2,2,3,3,0,0,0,0,0,0,0,0,0,0,1,1,1,2,2,3,3,3,4,4,4,0,0,0,0,0,0,0,1,1,1,2,2,2,3,3,3,4,4,4,
 
0,0,0,0,0,0,1,2,2,2,2,2,0,3,3,0,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
  x=array(x,dim=c(3,6,7))
  apply(x,3,function(.mat){

rows - table(apply(.mat,1,function(z){
# remove the zeros
z - z[z != 0]

paste(z,collapse=' ')
}))
# remove empty strings
rows - rows[names(rows) != ]

if (!is.null(rows)){
return(names(rows)[which.max(rows)])# return(table(names(rows)))
} else return(NULL)
  })

I am trying to get frequencies of all the sequences instead of most repeated 
using  return(table(names(rows))). But i could not get the desired results (i 
mean frequencies of all possible sequences)e.g. for first sector the result 
should be
1
3
and so on. Please suggest me some suitable way. Thanks 


Muhammad Azam


  
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


[R] request: table of sequences

2008-09-10 Thread Muhammad Azam
Dear R community
Thanks. The problem has been solved by just using return(rows) 

 
Muhammad Azam


  
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


[R] request: most repeated component of a list

2008-09-10 Thread Muhammad Azam
Dear R community
I have stored the results of arrays in a list consist of J-components (say 200 
components). Each component containing same no of columns but may be different 
no of rows. e.g
[[1]]
 [,1] [,2] [,3] [,4] [,5] 
[1,]40000   
[2,]43400   
[3,]43400   
[4,]43000   

[[2]]
 [,1] [,2] [,3] [,4] [,5] 
[1,]40000   
[2,]44300   
[3,]44300
[4,]44000
[5,]44000

[[3]]
 [,1] [,2] [,3] [,4] [,5] 
[1,]40000
[2,]44100
[3,]44100
[4,]44000

For 200 components i want to make a frequency table. How can i make a frequency 
table of these components or the most repeated component out of all? Any help 
in this regard will be appreciated. 

 
Muhammad Azam


  
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


[R] request: most repeated sequnce

2008-09-06 Thread Muhammad Azam
Dear R community
Hope every one be in best of his/her health. I have a situation in which there 
are s-sectors. Each sector is further divided into r-rows and c-columns. All it 
makes an array having dimension (r,c,s). e.g.

x=c(1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,2,2,2,3,3,0,0,0,0,0,0,0,0,0,0,1,1,1,2,2,3,3,3,4,4,4,0,0,0,0,0,0,0,1,1,1,2,2,2,3,3,3,4,4,4,
0,0,0,0,0,0,1,2,2,2,2,2,0,3,3,0,4,4,0,0,0,0,0,0)
x=array(x,dim=c(3,6,5))
 x
, , 1

 [,1] [,2] [,3] [,4] [,5] [,6]
[1,]100000
[2,]100000
[3,]100000

, , 2

 [,1] [,2] [,3] [,4] [,5] [,6]
[1,]123000
[2,]123000
[3,]120000

, , 3

 [,1] [,2] [,3] [,4] [,5] [,6]
[1,]123400
[2,]123400
[3,]134000

, , 4

 [,1] [,2] [,3] [,4] [,5] [,6]
[1,]123400
[2,]123400
[3,]123400

, , 5

 [,1] [,2] [,3] [,4] [,5] [,6]
[1,]120000
[2,]223400
[3,]223400 

I want to get the most repeated sequence (row-wise) of values in each sector. 
e.g. in sector 1 i.e. , , 1
the most repeated sequence is 1 (ignoring zeros). In , , 2 the most repeated 
sequence is 1  2  3. Similarly in last sector i.e. 
 , , 5 such sequence is  2  2  3  4. Any body can help to solve this problem. 
Thanks


best regards
Muhammad Azam



  
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


Re: [R] request: most repeated sequnce

2008-09-06 Thread Muhammad Azam
Dear R community
Initially i thought my problem has been solved but one thing which i found e.g. 
if  
1. All the elements of a sector are zero e.g
, , 7

 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,]000000000 0
[2,]000000000 0
[3,]000000000 0
[4,]000000000 0
[5,]000000000 0

2. Majority of the rows consist of zeros e.g.
, , 5

 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,]440000000 0
[2,]440000000 0
[3,]000000000 0
[4,]000000000 0
[5,]000000000 0

Actually
zeros are not my values. I get values and fill the remaining parts with
zeros like x=array(0,dim=c(3,6,5)). Now according to first strategy
000000000 0 are most repeated
sequence of rows in both of above cases. But i don't want to consider
cases where all elements are zeros and interested to get  44   
0000000 0 or just  4   4  in case 2. 
Thanks and best regards

Muhammad Azam





- Original Message 
From: jim holtman [EMAIL PROTECTED]
To: Muhammad Azam [EMAIL PROTECTED]
Cc: R Help r-help@r-project.org; R-help request [EMAIL PROTECTED]
Sent: Saturday, September 6, 2008 2:39:19 PM
Subject: Re: [R] request: most repeated sequnce

Here is a start.  You can delete the zeros:

 x=c(1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,2,2,2,3,3,0,0,0,0,0,0,0,0,0,0,1,1,1,2,2,3,3,3,4,4,4,0,0,0,0,0,0,0,1,1,1,2,2,2,3,3,3,4,4,4,
+ 0,0,0,0,0,0,1,2,2,2,2,2,0,3,3,0,4,4,0,0,0,0,0,0)
 x=array(x,dim=c(3,6,5))
 apply(x,3,function(.mat){
+ rows - table(apply(.mat,1,function(z){
+ paste(z,collapse=' ')
+ }))
+ names(rows[which.max(rows)])
+ })
[1] 1 0 0 0 0 0 1 2 3 0 0 0 1 2 3 4 0 0 1 2 3 4 0 0 2 2 3 4 0 0


On Sat, Sep 6, 2008 at 4:54 AM, Muhammad Azam [EMAIL PROTECTED] wrote:
 Dear R community
 Hope every one be in best of his/her health. I have a situation in which 
 there are s-sectors. Each sector is further divided into r-rows and 
 c-columns. All it makes an array having dimension (r,c,s). e.g.

 x=c(1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,2,2,2,3,3,0,0,0,0,0,0,0,0,0,0,1,1,1,2,2,3,3,3,4,4,4,0,0,0,0,0,0,0,1,1,1,2,2,2,3,3,3,4,4,4,
 0,0,0,0,0,0,1,2,2,2,2,2,0,3,3,0,4,4,0,0,0,0,0,0)
 x=array(x,dim=c(3,6,5))
 x
 , , 1

 [,1] [,2] [,3] [,4] [,5] [,6]
 [1,]100000
 [2,]100000
 [3,]100000

 , , 2

 [,1] [,2] [,3] [,4] [,5] [,6]
 [1,]123000
 [2,]123000
 [3,]120000

 , , 3

 [,1] [,2] [,3] [,4] [,5] [,6]
 [1,]123400
 [2,]123400
 [3,]134000

 , , 4

 [,1] [,2] [,3] [,4] [,5] [,6]
 [1,]123400
 [2,]123400
 [3,]123400

 , , 5

 [,1] [,2] [,3] [,4] [,5] [,6]
 [1,]120000
 [2,]223400
 [3,]223400

 I want to get the most repeated sequence (row-wise) of values in each sector. 
 e.g. in sector 1 i.e. , , 1
 the most repeated sequence is 1 (ignoring zeros). In , , 2 the most repeated 
 sequence is 1  2  3. Similarly in last sector i.e.
  , , 5 such sequence is  2  2  3  4. Any body can help to solve this problem. 
 Thanks


 best regards
 Muhammad Azam




[[alternative HTML version deleted]]

 __
 R-help@r-project.org 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.




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



  
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


[R] request: How to get column name

2008-09-03 Thread Muhammad Azam
Dear R community
I have a problem regarding which of the column in a matrix contains all of zero 
elements. e.g.
x=c(3,3,3,3,0,0,0,0,5,5,5,5,8,8,8,8); x=matrix(x, nrow=4)
the output is
 x
 [,1] [,2] [,3] [,4]
[1,]3058
[2,]3058
[3,]3058
[4,]3058
In this case the required column is second so the result should be 2. How can 
i get it? 

 
best regards

Muhammad Azam 



  
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


[R] request: To access a particular list

2008-06-27 Thread Muhammad Azam
Dear R community
I have a problem to access particular list. I have a code given below where 
there is recursive process. It is not possible to run it because there are few 
other functions involved inside like sv, LN, RN etc. 

k=0; n=0; variable=c(); vr-list()
func - function(data,testdata)
{
.
.
if(..){
  n-n+1; vr[[n]] - variable; print(vr)
  }else
{
k - k + 1; data1 = data; data2 = testdata; 
s=sv(data1)[[1]]; s1=s[1]; s2=s[2]; variable[k] - s1
data=LN(data1,s1,s2); testdata=LN(data2,s1,s2)  
   

func(data,testdata); 

data=RN(data1,s1,s2); testdata=RN(data2,s1,s2)

func(data,testdata)
 } 
} 
func(m,w)

Actually i made an global array to store s1 named variable. It contains k 
values. When it enters into if, i made a list of variable named vr. So it 
will make n lists. If i get the print out of vr, i will get
[[1]]
[1] 4

[[1]]
[1] 4

[[2]]
[1] 4 4 3

[[1]]
[1] 4

[[2]]
[1] 4 4 3

[[3]]
[1] 4 4 3

[[1]]
[1] 4

[[2]]
[1] 4 4 3

[[3]]
[1] 4 4 3

[[4]]
[1] 4 4 3

But if i print(vr[[n]]), i get result like an array
[1] 4
[1] 4 4 3
[1] 4 4 3
[1] 4 4 3
I want to access a particular list vr[[n-1]], but it gives an error 
Error in print(vr[[n - 1]]) : attempt to select less than one element. 
How can i tackle this problem to access vr[[n-1]]. Please give some suitable 
suggestions. 

Thanks and best regards

Muhammad Azam 



  
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


[R] request: a class having max frequency

2008-06-06 Thread Muhammad Azam
Dear R users
I have a very basic question. I tried but could not find the  required  result. 
using
dat - pima
f - table(dat[,9])

 f 
  0   1 
500 268
i want to find that class say 0 having maximum frequency i.e 500. I used
which.max(f)
which provide 
0 
1  
How can i get only the 0.  Thanks and 


best regards

Muhammad Azam 
Ph.D. Student 
Department of Medical Statistics, 
Informatics and Health Economics 
University of Innsbruck, Austria 


  
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


[R] request: An array declarion problem

2008-06-03 Thread Muhammad Azam
Dear R users
I tried a lot to solve the following problem but could not. I have two arrays 
having same order i.e 1 by 150. 

j=10; ss=150; r=array(0 , c( j , ss )); rr=array(0 , c( j , ss )); r1=array(0 , 
c( j-1 , ss )); r2=array(0 , c( j-1 , ss )); 
r3=array(0 , c( 2 , ss ))

for(i in 1:j-1){
r1[ i , ] - r[ j+1, ]-r[ j, ]; r2[ i , ] - rr[ j+1, 
]-rr[ j, ]
}

Now i want to rbind the results of r1 and r2 for each time. Now the order  of 
r3[ j, ] will become 2 by 150. I used the following form in the loop 

r3[ i,]=rbind(r1[ i, ], r2[ i, ])  

But there is an error message 

Error in r3[i, ] = rbind(r1[i, ], r2[i, ]) :  number of items to replace is not 
a multiple of replacement length


I am looking for some suggestion to solve the problem. Thanks and


best regards

Muhammad Azam 
Ph.D. Student 
Department of Medical Statistics, 
Informatics and Health Economics 
University of Innsbruck, Austria 


  
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


[R] request: To add an extra row in a matrix

2008-06-02 Thread Muhammad Azam
Dear R users
I have a problem regarding an addition of an extra row to a matrix. e.g. i 
have a matrix
a - matrix(1:6,2,3)
 a
 [,1] [,2] [,3]
[1,]135
[2,]246
I want to add a matrix having just one row. e.g.
b - matrix(7:9,1,3)

 b
 [,1] [,2] [,3]
[1,]789
Now i want to get result like this
 [,1] [,2] [,3]
[1,]135
[2,]246
[3,]789
Can any body help to get the required result.  Thanks and


best regards

Muhammad Azam 
Ph.D. Student 
Department of Medical Statistics, 
Informatics and Health Economics 
University of Innsbruck, Austria 


  
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


[R] request: which integer in each column is in majority

2008-05-28 Thread Muhammad Azam
Respected R helpers/ users
I am one of the new R user. I have a problem regarding to know which of the 
integer in each column of the following matrix is in majority. I want to know 
that integer e.g. in the first column 1 is in majority. Similarly in the third 
column 4 is in majority. So what is the suitable way to get the desired integer 
for each column. I am looking for some kind reply. Thanks
example:
 x=matrix(c(1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,4,1,2,3,3),ncol=4)
 x
 [,1] [,2] [,3] [,4]
[1,]1234
[2,]1241
[3,]1342
[4,]2343
[5,]2343

 
best regards

Muhammad Azam 
Ph.D. Student 
Department of Medical Statistics, 
Informatics and Health Economics 
University of Innsbruck, Austria 


  
[[alternative HTML version deleted]]

__
R-help@r-project.org 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.