On Tue, 2003-09-02 at 17:30, Dutky, Steve wrote:
I have a function that manipulates a list of numeric and character
components of equal length and wants to return a data.frame.
EG,
f-function() {
a-list(Int1=1:5,Char1=letters[1:5],Char2=letters[6:10])
b-data.frame(a)
}
Steve Dutky [EMAIL PROTECTED] wrote:
I have a function that manipulates a list of numeric and character
components of equal length and wants to return a data.frame.
...
How can I get the columns Char1, Char2, (...CharN) returned coerced to
character and not factor?
Prof Brian Ripley [EMAIL
, Steve Dutky
-Original Message-
From: Prof Brian Ripley [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 03, 2003 12:51 AM
To: Deepayan Sarkar
Cc: Dutky, Steve; '[EMAIL PROTECTED]'
Subject: Re: [R] How to avoid automatic coercion to factor?
Deepayan is correct, but note that I() creates
From ?data.frame:
Character variables passed to 'data.frame' are converted
to factor columns unless protected by 'I'. If a list or data frame
or matrix is passed to 'data.frame' it is as if each column had
been passed as a separate argument.
See the Examples section for an
Deepayan is correct, but note that I() creates a column of class AsIs,
not character. We should ask why you want character columns in a data
frame? (Certainly prior to 1.8.0 there is a fair chance that unless they
are of class AsIs manipulations would turn them into factors.)
If you really