Re: [R] cbind, data.frame | numeric to string?

2012-04-10 Thread R. Michael Weylandt
Don't use cbind() -- it forces everything into a single type, here string, which in turn becomes factor. Simply, data.frame(a, b, c) Like David mentioned a few days ago, I have no idea who is promoting this data.frame(cbind(...)) idiom, but it's a terrible idea (albeit one that seems to be very

Re: [R] cbind, data.frame | numeric to string?

2012-04-10 Thread Jessica Streicher
Still didn't work for me without cbind , although you really don't need it ;) worked after i set options(stringsAsFactors=F). options(stringsAsFactors=F) df-data.frame(intVec,chaVec) df intVec chaVec 1 1 a 2 2 b 3 3 c df$chaVec [1] a b c documentation of

Re: [R] cbind, data.frame | numeric to string?

2012-04-10 Thread Rainer Schuermann
cbind() works as well, but only if c is attached to the existing test variable: tst - cbind( test, c ) tst ab c

Re: [R] cbind, data.frame | numeric to string?

2012-04-10 Thread R. Michael Weylandt
Sorry, I missed that the OP's real question was in character/factor, not in the why are these all factors bit...good catch. Rant about cbind() still stands though. :-) [Your way with cbind() would give him all characters, not some characters and some numerics since cbind() gives a matrix by

Re: [R] cbind, data.frame | numeric to string?

2012-04-10 Thread David Winsemius
On Apr 10, 2012, at 11:58 AM, Rainer Schuermann wrote: cbind() works as well, but only if c is attached to the existing test variable: tst - cbind( test, c ) tst ab c 1 1 0.3 y1 2 2 0.4 y2 3 3 0.5 y3 4 4 0.6 y4 5 5 0.7 y5 str( tst ) 'data.frame': 5 obs. of 3

Re: [R] cbind, data.frame | numeric to string?

2012-04-10 Thread David Winsemius
On Apr 10, 2012, at 12:19 PM, David Winsemius wrote: On Apr 10, 2012, at 11:58 AM, Rainer Schuermann wrote: cbind() works as well, but only if c is attached to the existing test variable: tst - cbind( test, c ) tst ab c 1 1 0.3 y1 2 2 0.4 y2 3 3 0.5 y3 4 4 0.6 y4 5