Create Data Set Containing Random Integers with Duplicates
In this method to create the data set containing random integers with duplicates, the user needs to first install and import the random package in the working console and then call the randomNumbers() function of this package passed with the required parameters passed to it and the data set will be created accordingly in the R programming language.
Example:
In this example, we are calling the randomNumbers function of the random package passed with the n which is the total number of random numbers to be generated, min and max parameters are passed to set the limits of the generated random number, and the cols parameters id for the number columns required in the data set and further, we are printing the data set created using the random numbers with duplicates in the R programming language.
R
dataset= randomNumbers (n = 100, min = 0, max = 500, col = 5) dataset |
Output:
V1 V2 V3 V4 V5 [1,] 365 246 245 108 141 [2,] 146 278 8 48 438 [3,] 220 434 429 72 369 [4,] 272 121 282 257 210 [5,] 213 445 322 45 453 [6,] 355 127 145 196 166 [7,] 138 238 8 33 227 [8,] 437 380 477 272 416 [9,] 242 467 445 471 156 [10,] 399 293 125 56 188 [11,] 148 384 236 130 111 [12,] 493 158 143 102 484 [13,] 400 211 199 278 134 [14,] 31 160 357 455 313 [15,] 441 366 458 251 453 [16,] 441 329 79 360 105 [17,] 365 65 41 107 362 [18,] 442 288 380 234 223 [19,] 259 15 82 193 144 [20,] 119 134 485 349 7
Random Package in R
In this article, we will discuss the random package including its use with working examples in the R programming language.