Skip to content

Instantly share code, notes, and snippets.

Created February 14, 2018 03:56
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
r example using random numbers
# 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 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment