Skip to content
Prev 138529 / 398506 Next

Question on "assign(paste.."

Try:

	for(t in 4) { # Did you mean ``1:4''?
		nm <- paste("Trt",sep="")
		assign(nm,rmultinom(10,size=5,prob=probTrt[t,]))
		print(rowMeans(get(nm)))
	}

Notes:

	(1) You were missing the ``get(t)''; I introduced ``nm'' to save  
some typing.

	(2) You need the print() inside the for loop, or you won't see any  
results.

	(3) The letter ``t'' is a bad name for an index, since it is the  
name of the
	transpose function.  No *real* harm, but a dubious practice.

	(4) You'd probably be better off using a list, rather than constructing
	    a sequence of names.  As in

	Trt <- list()
	for(i in 1:4) {
		Trt[[i]] <- rmultinom(10,size=5,prob=probTrt[t,])
		print(rowMeans(Trt[[i]])
	}

		cheers,

			Rolf Turner
On 5/03/2008, at 1:44 PM, Kyeongmi Cheon wrote:

            
######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}