[R] How to output "0" after paste() ?
Rui Barradas
ruipbarradas at sapo.pt
Mon Feb 13 17:51:16 CET 2017
Hello,
See the help page for ?sprintf.
sprintf("why no dot zero %1.1f after init", aa)
Hope this helps,
Rui Barradas
Em 13-02-2017 16:27, vod vos escreveu:
> Hi everyone,
>
>
>
> How to get "0" after init?
>
>
>
> aa<- seq(2,7,0.5)
>
>
>
> aa
>
>
>
> [1] 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0
>
>
>
> bb<- paste("why no dot zero",aa,"after init",sep="")
>
>
>
> bb
>
>
>
> the output are:
>
>
>
> [1] "why no dot zero2after init" "why no dot zero2.5after init"
>
> [3] "why no dot zero3after init" "why no dot zero3.5after init"
>
> [5] "why no dot zero4after init" "why no dot zero4.5after init"
>
> [7] "why no dot zero5after init" "why no dot zero5.5after init"
>
> [9] "why no dot zero6after init" "why no dot zero6.5after init"
>
> [11] "why no dot zero7after init"
>
>
>
> What I want are like: "why no dot zero2.0after init" ,"why no dot zero3.0after init"
>
>
>
> I used round(), signif(), but it does not help. Any ideas?
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>
More information about the R-help
mailing list