[S] complex numbers and print()

Pierre Kleiber (pkleiber@honlab.nmfs.hawaii.edu)
Sat, 21 Nov 1998 16:14:05 -1000 (HST)


print.data.frame() seems confused when the data frame contains complex
numbers:

> data.frame(a=sample(1:5),b=complex(re=sample(1:5),im=sample(1:5)))
a b
1 3+0i 3+1i
2 5+0i 2+5i
3 2+0i 5+3i
4 1+0i 4+4i
5 4+0i 1+2i

i.e. it forces plain real numbers to print as complex numbers.
Interstingly, the plain real number format is "protected" if the data
frame contains a factor variable:

> data.frame(a=sample(1:5),b=complex(re=sample(1:5),im=sample(1:5)),c=letters[1:5])
a b c
1 1 4+3i a
2 5 2+1i b
3 3 1+4i c
4 2 3+5i d
5 4 5+2i e

Perhaps someone will argue that this is a feature, but for me it's a
bug. Is there some way to keep complex number formatting where it
belongs other than adding a bogus factor variable?

In case it's relevant, I'm running Version 3.4 Release 1 for Silicon
Graphics Iris, IRIX 5.3 : 1996

CHeers, Pierre

-- 
-----------------------------------------------------------------
Pierre Kleiber             Email: pkleiber@honlab.nmfs.hawaii.edu
Fishery Biologist                     Tel: 808 983-5399/944-1855
NOAA FISHERIES - Honolulu Laboratory         Fax: 808 983-2902
2570 Dole St., Honolulu, HI 96822-2396 
-----------------------------------------------------------------
-----------------------------------------------------------------------
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