Created
May 12, 2016 16:39
-
-
Save nwstephens/062627ef3aec7dc8a802d7e671fe34b1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Turn on profvis in RStudio first and run this code second | |
| # No preview panel appears and flamechart does not represent | |
| library(profvis) | |
| # Generate data | |
| times <- 4e5 | |
| cols <- 150 | |
| data <- as.data.frame(x = matrix(rnorm(times * cols, mean = 5), ncol = cols)) | |
| data <- cbind(id = paste0("g", seq_len(times)), data) | |
| profvis({ | |
| data1 <- data # Store in another variable for this run | |
| # Get column means | |
| means <- apply(data1[, names(data1) != "id"], 2, mean) | |
| # Subtract mean from each column | |
| for (i in seq_along(means)) { | |
| data1[, names(data1) != "id"][, i] <- data1[, names(data1) != "id"][, i] - means[i] | |
| } | |
| }, height = "400px") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment