Hello everyone! I would like to have a plot with some points in different colors; but I get an empty plot. Could someone help me?
a=data.frame(b= c(1:26), c=rnorm(26), d=paste(letters[1:26]))
e=data.frame(a$d[3:15])
colnames(e)=c("d1")
variant 1
plot(a$b, a$c, col= (if (a$b<5) {'red'} else (for (i in 1:26) {if (a$d[i] == e$d1) {'blue'} else {'black'}})))
Warning message: In if (a$b < 5) { : the condition has length > 1 and only the first element will be used
variant 2
plot(a$b, a$c, col= for (i in 1:26) {if (a$d[i]%in%e$d1) {'blue'} else {'black'}})
Warning message: In if (a$b < 5) { : the condition has length > 1 and only the first element will be used
d are the labels of each element coordinates (b;c), number of elements =26
e: data frame with a subset of character elements from a$d
I would like the elements a$b < 5 in red, a$d == e$d1 to b colored in ‘blue’ and the rest in ‘black’ Thanks in advance Roberto