[R] SOS

jim holtman jholtman at gmail.com
Fri Jul 20 19:44:14 CEST 2007


You can use sprintf:

> x <- runif(5)
> x
[1] 0.89838968 0.94467527 0.66079779 0.62911404 0.06178627
> cat(sprintf("%.2f%% ", x * 100))
89.84%  94.47%  66.08%  62.91%  6.18% >


On 7/20/07, Fabrice McShort <fabricemcshort at hotmail.com> wrote:
> Hi Julian,
>
> Thank you very much. Please let me know how to get 2 numbers after the decim.
>
> Best regards,
>
> Fabrice
>
>
>
> > Date: Fri, 20 Jul 2007 08:15:42 -0700> From: jmburgos at u.washington.edu> To: fabricemcshort at hotmail.com> CC: r-help at stat.math.ethz.ch> Subject: Re: [R] SOS> > Multiply by 100? Add> > R=R*100> > Fabrice McShort wrote:> > Dear all, I am a new user of R. I would like to know how to get fund's returns in percentage (%). For example, I use: R <- ts(read.xls("FundData"), frequency = 12, start = c(1996, 1)) Whith this program, the returns are like 0.0152699. But, I would like to have 1.52%. Please advise me about the function. Thanks! Fabrice> > _________________________________________________________________> >> > [[trailing spam removed]]> >> > [[alternative HTML version deleted]]> >> > ______________________________________________> > R-help at stat.math.ethz.ch 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.> >> > > > !
>  -- > Julian M. Burgos> > Fisheries Acoustics Research Lab> School of Aquatic and Fishery Science> University of Washington> > 1122 NE Boat Street> Seattle, WA 98105 > > Phone: 206-221-6864> >
> _________________________________________________________________
>
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>


-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?



More information about the R-help mailing list