Dear R users,

I have two simple questions here, and hope someone can help me on this. Thanks 
in advance.

1.
I have a list object lst=list(a1=matrix(rnorm(4),2,2), 
a2=matrix(rnorm(4),2,2),a3=matrix(rnorm(4),2,2)). Here I only use three 
elements for illustration, and in fact the length of lst, n, is unknown in 
advance. I want to define an object for each element of this lst, and the 
objects have names like "object1", "object2",...,"objectn". I could use a loop 
like the following:
for (i in 1:length(lst)){
        assign(paste("object",i,sep=""),lst[[i]])
}

I wonder if there's a way to avoid this loop? 


2.
I want to validate whether all of the "object"s have the same dimension, that 
is, whether dim(object1)[1]==dim(object2)[1]==dim(object3)[1]& 
dim(object1)[2]==dim(object2)[2]==dim(object3)[2]  is true. How can I do that 
easily since the length of lst is not fixed?

Thanks.

Wayne (Yanwei) Zhang 
Ttatistical *esearch 
> CNA
> 
> 
> 

E-MAIL CONFIDENTIALITY NOTICE:  The contents of this e-mail message and any 
attachments are intended solely for the
addressee(s) and may contain confidential and/or legally privileged 
information. If you are not the
intended recipient of this message or if this message has been addressed to you 
in error, please
immediately alert the sender by reply e-mail and then delete this message and 
any attachments. If you
are not the intended recipient, you are notified that any use, dissemination, 
distribution, copying, or
storage of this message or any attachment is strictly prohibited.

        [[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.

Reply via email to