Re: [R] Simple loop code

2010-05-03 Thread RCulloch
Thanks David & Henrique, I've been using R for over two years and always used cbind or rbind, that was what I was taught by several folk, and on training courses, you learn something new every day! Cheers, Ross -- View this message in context: http://r.789695.n4.nabble.com/Simple-loop-code-t

Re: [R] Simple loop code

2010-04-29 Thread David Winsemius
On Apr 29, 2010, at 1:42 PM, Henrique Dallazuanna wrote: On Thu, Apr 29, 2010 at 12:05 PM, David Winsemius > wrote: snipped ##Then bind to your data z <- cbind(y,x) Oooh. Not a good practice, at least for the newish useR. cbind and rbind create matrices and as a consequence coerce a

Re: [R] Simple loop code

2010-04-29 Thread Henrique Dallazuanna
On Thu, Apr 29, 2010 at 12:05 PM, David Winsemius wrote: > > On Apr 29, 2010, at 10:37 AM, RCulloch wrote: > > >> Thanks Henrique, >> >> that works! for anyone else as slow as me, just: >> >> ##Assign >> x <- factor(dat.ID$ID2, labels = 1:7) >> ##Convert to dataframe >> x <- as.data.frame(x) >> >

Re: [R] Simple loop code

2010-04-29 Thread David Winsemius
On Apr 29, 2010, at 10:37 AM, RCulloch wrote: Thanks Henrique, that works! for anyone else as slow as me, just: ##Assign x <- factor(dat.ID$ID2, labels = 1:7) ##Convert to dataframe x <- as.data.frame(x) The more typical methods for converting a factor to a character vector would be: (

Re: [R] Simple loop code

2010-04-29 Thread RCulloch
Thanks Henrique, that works! for anyone else as slow as me, just: ##Assign x <- factor(dat.ID$ID2, labels = 1:7) ##Convert to dataframe x <- as.data.frame(x) ##Then bind to your data z <- cbind(y,x) Thanks again, I expected it to be more complicated! Cheers, Ross -- View this message in

Re: [R] Simple loop code

2010-04-29 Thread Henrique Dallazuanna
Try this: factor(dat.ID$ID2, labels = 1:7) On Thu, Apr 29, 2010 at 8:39 AM, RCulloch wrote: > > Hi fellow R Users, > > I find that I typically rewrite my data specific to data in columns, which > is by no means efficient and I am struggling to break out of this bad habit > and utalise some of t