Last active
October 17, 2016 04:35
-
-
Save 1beb/183511b51d615751860204344a02c799 to your computer and use it in GitHub Desktop.
This file contains 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
library(data.table) | |
size = 1e6 | |
resample <- function(x,size = 1e6) sample(x,size,replace = TRUE) | |
text <- c("Canada","Peru","Australia","Angola","France","", NA_character_) | |
text2 <- c("Oh Canada.","Arriba Peru.","Australia?","Vive la France.") | |
numerics <- rnorm(1e6) | |
dt <- data.table( | |
id = as.character(1:1e6), | |
i1 = resample(c(as.character(c(0:5,NA)),"")), # sometimes just blank | |
i2 = resample(c(as.character(c(100:500,NA)))), | |
n1 = as.character(round(rnorm(1e6),3)), | |
t1 = resample(text), | |
t2 = resample(text2) | |
) | |
for(j in names(dt)) set(dt, j = j, value = type.convert(dt[[j]]) | |
str(dt) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment