hello,
i have written a function to extract certain lines from a matrix. the
result is a matrix with 6 cols, named dynamically according to the
functions arguments.
the problem is now, that i'm not able to return the resultmatrix for
further use. the object is not being created.
example from my console:
getans(27,27)
[...]
[189,] 3969 161 27 1 0 1
[190,] 2142 87 27 1 0 1
[191,] 1318 52 27 1 0 1
[192,] 2881 120 27 1 0 1
[193,] 3669 152 27 1 0 1
[194,] 5653 229 27 1 0 1
[195,] 2308 95 27 1 0 2
[196,] 4942 200 27 1 0 1
the matrix ansblock27 contains answers to block 27
> ansblock27
error: object "ansblock27" not found
>
the code of the function:
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])))
#create result matrix
assign(matnam,matrix(as.numeric(as.matrix(allans[(allans[, 3] %in%
x), , drop = FALSE])),ncol=dim(allans)[2]))
#print info
cat("the matrix",matnam,"contains answers
to",type,as.character(bnr))
}
i have tried to use "return", but had no success.
what else can i do?
thx in advance, and have a nice weekend
regards,
[[alternative HTML version deleted]]