Reputation: 1
I want to generate a numeric vector of random numbers between 0 and 5,000 of length 2,500 and call it x.
Then I want to make a numeric vector y of all the numbers between 0 and 5,000 which aren't in x, which by definition is also length 2,500.
Then for each of these vectors I'd like to extract the corresponding row numbers from a table. Is there an easy way to do this?
Upvotes: 0
Views: 326
Reputation: 70643
You can try this. The main
object holds a table with two columns (you can think of them as your x
and y
).
main <- sample(1:5000, 5000)
main <- matrix(main, ncol = 2)
head(main)
[,1] [,2]
[1,] 3146 4834
[2,] 4129 4297
[3,] 510 1843
[4,] 4513 1167
[5,] 1281 2550
[6,] 1076 4377
Upvotes: 2