[R] Question on "assign(paste.."

From: Kyeongmi Cheon <katie.cheon_at_gmail.com>
Date: Tue, 04 Mar 2008 18:44:42 -0600

I'm having trouble in using "assign(paste ..." command . I could create several dataframes following trinomial distribution using it but it could not be used to check their row means of the created dataframe.

For example, the following works:

#malf, death, normal

probTrt[1,]=c(0.064,0.119,0.817);#for Trt 1
probTrt[2,]=c(0.053,0.125,0.823);#for Trt 2
probTrt[3,]=c(0.111,0.139,0.750);#for Trt 3
probTrt[4,]=c(0.351,0.364,0.285);#for Trt 4
for (t in 4){
        assign(paste("Trt",t,sep=""),rmultinom(10, size = 5,


But the following does not work.
for (t in 4){

        assign(paste("Trt",t,sep=""),rmultinom(10, size = 5, prob=probTrt[t,]));


How can I use it in functions like rowMeans so that I don't have to type all the object names? Thank you.


        [[alternative HTML version deleted]]

R-help_at_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. Received on Wed 05 Mar 2008 - 02:10:04 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 05 Mar 2008 - 03:30:19 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive