简体   繁体   English

如何使用c()在r中生成实数序列?

[英]how to use c() to generate a sequence of real numbers in r?

I know that using c(*start_no*:*end_no*) in R returns a sequence of numbers from start_no to end_no like 我知道在R中使用c(*start_no*:*end_no*)返回从start_noend_no的数字序列,例如

> c(1:10)
 [1]  1  2  3  4  5  6  7  8  9 10

But I want c() to print in the following pattern 但我希望c()以以下模式打印

> c(0.1:0.9)
 [1]  0.1  0.2  0.3  0.4  0.5  0.6  0.7  0.8  0.9

Ideas on how to accomplish this by only using c() in R? 关于仅通过在R中使用c()来实现此目的的想法?

I think, you cannot directly use it. 我认为,您不能直接使用它。 However, you can manipulate it like 但是,您可以像

c(1:10)/10

# [1] 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM