s-news
[Top] [All Lists]

Re: Coercing to character

To: <asanquer@virbac.fr>
Subject: Re: Coercing to character
From: "Dimitris Rizopoulos" <dimitris.rizopoulos@med.kuleuven.be>
Date: Tue, 6 Sep 2005 14:48:29 +0200
Cc: <s-news@wubios.wustl.edu>
References: <OFBB1765FD.2178DAB6-ONC1257074.00443BD1-C1257074.0045049C@virbac.fr>
you could try format(), e.g.,

x <- c(3.45, 3.40)
format(x)

see ?format for more info and options.

I hope it helps.

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.be/biostat/
    http://www.student.kuleuven.be/~m0390867/dimitris.htm


----- Original Message ----- From: <asanquer@virbac.fr>
To: <s-news@wubios.wustl.edu>
Sent: Tuesday, September 06, 2005 2:33 PM
Subject: [S] Coercing to character






Hi,

I've got a problem when I coerce a numeric value to a character: I loose
some decimal digits after the decimal point.

Example:

x <- c(3.45,3.40)
as.character(x)
[1] "3.45" "3.4"

I really want to keep the 2 decimal digits. Does someone can give me a
tip-off?

I had also noted that when I export some data frame to an ASCII file, I loose the null decimal digit (with numeric data). An explanation and may be
a solution?

Thank a lot,

Annaële Sanquer

--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu.  To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message:  unsubscribe s-news


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm


<Prev in Thread] Current Thread [Next in Thread>