Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道 1:10 会给我一个从 1 到 10 的所有整数的向量,但是我怎样才能让从 1 到 2 的数字上升十分之一(即 1.0、1.1、1.2、...、2.0)?
尝试seq
seq
> seq(1, 2, by = 0.1) [1] 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0
只是本着不止一种做事方式的精神,另一种选择是:
> (10:20)/10 [1] 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0