[R] Expressing number in percentage

S Ellison S.Ellison at lgc.co.uk
Fri Sep 28 11:13:17 CEST 2007


Or paste(x,"%")



>>> Marc Schwartz <marc_schwartz at comcast.net> 27/09/2007 15:56:05 >>>
On Thu, 2007-09-27 at 14:36 +0100, stat stat wrote:
> I am wondering if there is any procedure to write a particular value
> in Percentage format, still maintaining it's numeric character. for
> example I want to write '.33' as '33%' 

See ?sprintf

> sprintf("%.0f%%", .33 * 100)
[1] "33%"


Note that the trailing '%' needs to be doubled to be recognized as the
character and not a format specifier.

HTH,

Marc Schwartz

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help 
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html 
and provide commented, minimal, self-contained, reproducible code.

*******************************************************************
This email contains information which may be confidential and/or privileged, and is intended only for the individual(s) or organisation(s) named above. If you are not the intended recipient, then please note that any disclosure, copying, distribution or use of the contents of this email is prohibited. Internet communications are not 100% secure and therefore we ask that you acknowledge this. If you have received this email in error, please notify the sender or contact +44(0)20 8943 7000 or postmaster at lgcforensics.com immediately, and delete this email and any attachments and copies from your system. Thank you. 

LGC Limited. Registered in England 2991879. 
Registered office: Queens Road, Teddington, Middlesex TW11 0LY, UK


More information about the R-help mailing list