Re: [R] What's the BEST way in R to adapt this vector?

2008-11-23 Thread zerfetzen
Thanks for the help, I've a few more functions to get familiar with. Those are definitely concise ways to do this! :) -- View this message in context: http://www.nabble.com/What%27s-the-BEST-way-in-R-to-adapt-this-vector--tp20638991p20647978.html Sent from the R help mailing list archive at

Re: [R] What's the BEST way in R to adapt this vector?

2008-11-23 Thread Jagat.K.Sheth
bEST is up to you to define. Here is one simple way y.new - c(t(model.matrix(~factor(y)-1))) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of zerfetzen Sent: Saturday, November 22, 2008 12:00 PM To: r-help@r-project.org Subject: [R] What's the BEST way

[R] What's the BEST way in R to adapt this vector?

2008-11-22 Thread zerfetzen
Goal: Suppose you have a vector that is a discrete variable with values ranging from 1 to 3, and length of 10. We'll use this as the example: y - c(1,2,3,1,2,3,1,2,3,1) ...and suppose you want your new vector (y.new) to be equal in length to the possible discrete values (3) times the length

Re: [R] What's the BEST way in R to adapt this vector?

2008-11-22 Thread hadley wickham
On Sat, Nov 22, 2008 at 12:00 PM, zerfetzen [EMAIL PROTECTED] wrote: Goal: Suppose you have a vector that is a discrete variable with values ranging from 1 to 3, and length of 10. We'll use this as the example: y - c(1,2,3,1,2,3,1,2,3,1) ...and suppose you want your new vector (y.new) to

Re: [R] What's the BEST way in R to adapt this vector?

2008-11-22 Thread Gabor Grothendieck
Try this: outer(y, sort(unique(y)), ==)+0 On Sat, Nov 22, 2008 at 3:37 PM, zerfetzen [EMAIL PROTECTED] wrote: Goal: Suppose you have a vector that is a discrete variable with values ranging from 1 to 3, and length of 10. We'll use this as the example: y - c(1,2,3,1,2,3,1,2,3,1) ...and

Re: [R] What's the BEST way in R to adapt this vector?

2008-11-22 Thread Berwin A Turlach
On Sat, 22 Nov 2008 10:00:18 -0800 (PST) zerfetzen [EMAIL PROTECTED] wrote: Goal: Suppose you have a vector that is a discrete variable with values ranging from 1 to 3, and length of 10. We'll use this as the example: y - c(1,2,3,1,2,3,1,2,3,1) ...and suppose you want your new vector