Created
August 14, 2019 21:47
-
-
Save bfatemi/35f112e6d9038a07337c87aa19bd8207 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
set_sample_view <- function(){ | |
selectText <- rstudioapi::primary_selection(rstudioapi::getSourceEditorContext())$text | |
exprList <- rlang::parse_exprs(selectText) | |
w <- get("(") | |
exprDF <- exprList[[which(sapply(exprList, function(x) is.data.frame(w(eval(x)))))]] | |
invisible(eval(exprDF)) | |
DT <- data.table::as.data.table(w(eval(exprDF))) | |
vdf <- DT[sample(seq_len(.N), size = min(100, .N), replace = FALSE)] | |
return(vdf) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment