Last active
February 5, 2016 15:16
-
-
Save rBatt/afe78e920321b446fb64 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
df <- data.frame(x = rnorm(20, mean=20, sd = 10)) | |
threshold <- 25 | |
replace_val <- 0 | |
df[,"x2"] <- df[,"x"] # make them the same to start | |
df[df[,"x"] >= threshold, "x2"] <- replace_val # replace values at or above threshold with replacement value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment