[S] Un Factor (Replies)

PT Quants Group Dir (ptquants@nyptsrv1.etsd.ml.com)
Fri, 13 Nov 1998 13:26:12 -0500


Hi,

I thought I should send this prior to getting anymore as.character() examples.
And some people wanted solution to this annoying problem. So, here it goes.

I found an interesting twist though
Bill Dunlap wrote: (Thanks Bill)

> If you have a data frame, "df", containing a factor column, "Text",
> you can turn it into a character column with
> df$Text <- I(as.character(df$Text))
> or
> df[,"Text"] <- I(as.character(df[,"Text"]))
> There are a couple of other ways to replace a column of a data frame
> as well. The important part is to use I(characterdata) so the
> data frame code doesn't try to convert it to a factor. (With some
> syntaxes this I isn't needed, but you might as well use it.)

I did not know about I() function. This was helpful.

Calling Splus tech support, which took me forever to get through. I found out
that there is no way to turn this off for odbc. (You can do it with import
files, however)
And that middle pull down window from datasheet that shows you character,
double, etc.. useless. You must go Menu:Data, change data type, etc... This
means that I cannot let my users play around with this thing. I will just use
command line as before.
Another thing is that the field size on character is imported as is. So, if
had 12 character field, well you got "ACB " thing with appeneded empty white
spaces. To get rid of it simple, but took quite a bit of digging into docs.
Splus do not have trim(str) or string.strip(str) unlike VB or Python. So, I
had to use
substring(z, 1, regexpr(" +", z)) to strip out right blanks. At least it's got
regex.
Many thanks to people who responded quickly back with as.character. I should
have formed my question little better to say that I wanted GUI solution for my
users.

S.Y.

P.S.: Getting through to Splus support is really really tough nowadays. Gee
Whiz... I am having major problem with my traders because I am stuck holding on
to
damn phone for tech support.
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news