我有一个散点图,我想对点进行着色,以便满足这两个条件的所有点都是红色的。条件是abs(x) > .15
和abs(y)>1.4
colour <- ifelse(abs(x)>.15, "red", "black")
colour <- ifelse(abs(y)>1.4, "red", "black")
# colour <- ifelse((abs(y)>1.4&&abs(x)>.15), "red", "black") #all black
plot(y, x, main="scatter - meth vs exp - diff", xlab="delta beta (.15)", ylab="log2(exp)", col=colour)
abline(h=c(-1.4, 1.4), v=c(-.15, .15), col="gray", lty=3)
我在这里缺少什么?感谢任何建议。
答案 0 :(得分:1)
这是否会产生预期效果?
x <- rnorm(10)
y <- rnorm(10)
colour <- ifelse(abs(x)>.15 & abs(y)>1.4, "red", "black")
# colour <- ifelse((abs(y)>1.4&&abs(x)>.15), "red", "black") #all black
plot(y, x, main="scatter - meth vs exp - diff", xlab="delta beta (.15)", ylab="log2(exp)", col=colour)
abline(h=c(-1.4, 1.4), v=c(-.15, .15), col="gray", lty=3)
使用&
组合这两个条件。