[R] Several Basic Questions
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue May 20 16:12:07 CEST 2003
On Tue, 20 May 2003, Minghua Yao wrote:
> I am having several basic questions that I haven't found the answer to from
> the manuals:
> 1. How to remove "" when a single line message is printed?
> 2. How to print several variables (e.g., a character string and a numeric
> variable) at the same line?
> 3. How to have the control of the accuracy of variables? e.g., in the
> > x<-1134567.1
> > y<-0.19
> > z<-x-y
> > z
>  1134567
> I want variable to have an accuracy of 2 digits behind the decimal point
> instead of all the digits behind the point being cut off.
Use cat, round and format:
> cat(format(round(z, 2)), "\n")
These may not be explicit in the R manuals, but they are in all good books
on R (see the FAQ).
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help