Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
r example using random numbers
require(tictoc)
tic()
# create a 250 col x 80000 row matrix of random uniform (0,1) numbers
random_numbers <- matrix( runif(250 * 80000), ncol=250)
#square root of the random numbers
sqrt_random_numbers <- sqrt(random_numbers)
#mean of each column
column_means <- colMeans(sqrt_random_numbers)
# create a random index of 80000 values between 1 and 80000 then get the data from sqrt_random_numbers
# from the 4th column and put that all in a vector
resample_index <- sample(1:80000, 80000, replace=T)
## pulls the item from the 4th column of the squared matrix that correspond to the resampled index
resorted_4th_column <- sqrt_random_numbers[ resample_index ,4 ]
toc()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment