Skip to content

Instantly share code, notes, and snippets.

@alexhallam
Created June 5, 2018 20:35
Show Gist options
  • Save alexhallam/8881ff662595b7cfb57f3e80f0efd91e to your computer and use it in GitHub Desktop.
Save alexhallam/8881ff662595b7cfb57f3e80f0efd91e to your computer and use it in GitHub Desktop.
Test Train Split In dplyr with mutate
# Test/Train split
set.seed(2018) # for reproducability
daily %>%
mutate(test_train = ifelse(rbinom(n=n(), size = 1, prob = .75) == 1,
"train","test")) %>%
count(test_train)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment