0
Follow
0
View

rep(x, each=y) gives incomplete output in R

cxfyylx 注册会员
2023-01-25 21:50

I don't get how the output should look like, so make a simple example showing the output.

v1 <- 4:6
v2 <- 1:3

rep(v1, v2)
#[1] 4 5 5 6 6 6

rep_len(v1, sum(v2))
#[1] 4 5 6 4 5 6

#gives a WARNING, that only the first element of v2 is used
rep(v1, each=v2)
#[1] 4 5 6

About the Author

Question Info

Publish Time
2023-01-25 21:50
Update Time
2023-01-25 21:50