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
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
cbind() works as well, but only if c is attached to the existing test variable:
tst - cbind( test, c )
tst
ab c
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
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
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
6 matches
Mail list logo