[R] Formatting numeric values in a data frame
Pele
drdionc at yahoo.com
Wed Feb 25 22:19:36 CET 2009
Hi R users,
I have a data frame that contains 10K obs and 200 variables
where I am trying to format the numeric columns to look
like the output table below (format to 2 decimal places) but I am
having no luck.. Can someone tell me the best way to
accomplist this?
Thanks in advance for any help!
str(ad.test)
'data.frame': 10,000 obs. of 200 variables:
$ ID : Factor w/ ..................
$ x1 : num 0.1123334 0.4778966..........
$ x2 : num 0.00002 0.00002..............
$ x3 : num 12.33338 9.44446.............
====================================================
Data.frame....
ID x1 x2 x3
a1 0.0123334 0.000020000 12.33338
b3 0.477896366 0.000020000 9.44446
c1 0.477896366 0.000020000 9.44446
d5 0.477896366 0.000020000 9.44446
e1 0.477896366 0.000020000 9.44446
f2 0.477896366 0.000020000 9.44446
g6 0.333333333 0.000020000 9.44446
h8 0.333333333 0.000020000 9.44446
i2 0.333333333 0.000020000 9.44446
k2 0.333333333 0.000020000 9.44446
=========================================================
Output:
ID x1 x2 x3
a1 0.01 0.00 12.33
b3 0.48 0.00 9.44
c1 0.48 0.00 9.44
d5 0.48 0.00 9.44
e1 0.48 0.00 9.44
f2 0.48 0.00 9.44
g6 0.33 0.00 9.44
h8 0.33 0.00 9.44
i2 0.33 0.00 9.44
k2 0.33 0.00 9.44
--
View this message in context: http://www.nabble.com/Formatting-numeric-values-in-a-data-frame-tp22212031p22212031.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list