Dear Simon,

One doesn't generally use cbind.data.frame() directly, but rather through the generic function cbind(). I believe that the following will give you what you want:

fac <- factor(c(rep(1,7), rep(2,3)))
cbind(fac, as.data.frame(mat))

where mat is the matrix.

I hope that this helps,
 John



At 08:43 PM 2/3/2004 +1100, Simon Hosking wrote:
Hi list,
I'd like to make a factor with seven 1s and three 2s using the
factor() function.
That is,

1
1
1
1
1
1
1
2
2
2


I will then bind this factor to the matrix below using cbind.data.frame().


0.56    0.48
0.22    0.59
0.32    0.64
0.26    0.60
0.25    0.38
0.24    0.45
0.56    0.67
0.78    0.97
0.87    0.79
0.82    0.85



I am new to R and have been using various manuals and have made many attempts without success
any help appreciated.
thanks,
Simon

----------------------------------------------------- John Fox Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 email: [EMAIL PROTECTED] phone: 905-525-9140x23604 web: www.socsci.mcmaster.ca/jfox

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to