Created
September 9, 2012 14:52
-
-
Save cdesante/3684833 to your computer and use it in GitHub Desktop.
Basic Plot in R with Conditional Coloring
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
#Plotting Random Variables | |
#rnorm(N, mean, sd): generates a | |
#random normal variable of length N | |
#with specified mean and std. dev. (sd) | |
# x/ylim = range of X/Y axis. | |
#col: colors, specified with an ifelse() | |
#pch, plot symbol to use | |
#pch list: http://voteview.com/symbols_pch.htm | |
X <- rnorm(500) #draw var 1 | |
Y <- rnorm(500) #draw var 2 | |
plot(X, Y, xlim=c(-3,3),ylim=c(-3,3), | |
col=ifelse(((abs(X)>1.65 & abs(Y)>1.65)),"red", "black"), | |
main="Two Dimensional Outliers (in red)" , | |
pch=ifelse(((abs(X)>1.65 & abs(Y)>1.65)), 17, 1) | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just for S's and giggles.