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.
是否有一种优雅的方法可以为向量的每个索引取上限(如果输入不是整数)或大一个整数(如果输入是整数)?
这样,例如,向量 x
x = c(0, 4, 5.3333, 6.25)
变成向量 y
1, 5, 6, 7
这以不同的方式思考这个问题
y <- floor(x+1)
> y [1] 1 5 6 7