📜  在 R 编程中复制指定次数的值 - rep.int()函数

📅  最后修改于: 2022-05-13 01:54:43.362000             🧑  作者: Mango

在 R 编程中复制指定次数的值 - rep.int()函数

R 语言中的rep.int()函数用于将给定值复制到指定次数。

示例 1:

# R program to illustrate
# rep.int function
  
# Calling the rep.int() function
rep.int(1:2, 2)
rep.int(1:3, 1)
rep.int(0:1, 4)

输出:

[1] 1 2 1 2
[1] 1 2 3
[1] 0 1 0 1 0 1 0 1

示例 2:

# R program to illustrate
# rep.int function
  
# Calling the rep.int() function
rep.int(c(1, 2), 2)
rep.int(c(1, 2, 3), 3)
rep.int(c(5), 6)

输出:

[1] 1 2 1 2
[1] 1 2 3 1 2 3 1 2 3
[1] 5 5 5 5 5 5