Skip to content
Prev 262368 / 398502 Next

scatterplot3d - help assign colors based on multiple conditions

On 06/10/2011 06:40 AM, Karthik Kota wrote:
Hi Karthik,
Your problem is that you are assigning all of the values to "col" twice. 
If you reverse the order of the statements you will get the red/black 
color set. Try this:

col<-rep("black",dim(cdh1)[1])
col[grepl("_Anterior_nares", xlabels) &
  grepl("_Anterior_nares", ylabels)]<-"red"
col[grepl("_Tongue_dorsum", xlabels) &
  grepl("_Tongue_dorsum", ylabels)]<-"blue"

If your two conditions specify disjunct sets, that is, no case satisfies 
both conditions, you should have the correct vector of colors.

Jim