Scatterplot: Colour distribution vector

The aim is to create a vector that has the colour distribution KG=0 -> grey; EG=1-> dark green) to match the groups. Unfortunately, my colour vector does not have the same length and distribution as the variable group.

colors = c("grey","darkgreen")
colors2 <- colors[as.numeric(df_2a_red_long_cleanpair$Gruppe)]

thank you

I would do it like this

(df_2a_red_long_cleanpair <- data.frame(Gruppe=c(rep("EG=1",5),
                                                rep("KG=0",3))))

colors <- c("KG=0"="grey",
            "EG=1"="darkgreen")
(colors2 <- colors[df_2a_red_long_cleanpair$Gruppe])
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.