On Mar 3, 2007, at 4:28 PM, bunny , lautloscrew.com wrote:
Please use <- for assignments instead of = :
> getans = function(x=qids,bnr=1,type="block")
> {
> #generate name of matrix
> matnam=paste("ans",type,as.character(bnr),sep="")
>
> #display result matrix
> show(assign(matnam,matrix(as.numeric(as.matrix(allans[(allans[, 3] %in
> % x), , drop = FALSE])),ncol=dim(allans)[2])))
You are assigning things twice here.
> #create result matrix
> assign(matnam,matrix(as.numeric(as.matrix(allans[(allans[, 3] %in%
> x), , drop = FALSE])),ncol=dim(allans)[2]))
The documentation for assign makes it pretty clear that the
assignment happens by default in the current environment, so it will
be local to the function unless you alter the call. The description
there, along with the examples, and a study of environments, should
provide you with the answer.
> #print info
> cat("the matrix",matnam,"contains answers to",type,as.character
> (bnr))
>
> }
Haris Skiadas
Department of Mathematics and Computer Science
Hanover College
______________________________________________
[email protected] 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.