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]]
First, use plain text emails. Look that what conversion from html did to your
email:
aa <- seq(2,7,0.5) became aa<- seq(2,7,0.5)
You need to format your numeric values with sprintf():
paste("why no dot zero", sprintf("%3.1f", aa),"after
init",sep="")
?sprintf for details
-------------------------------------
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352
-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of vod vos
Sent: Monday, February 13, 2017 10:28 AM
To: r-help <r-help at r-project.org>
Subject: [R] How to output "0" after paste() ?
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.
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.
>