Is there a way to let R use data respective of another column?

35 Views Asked by At

I have a data set that is has colnames "Phenotype" and "Phenotype_Measurement" (total dataset named "ThermalVar"). I'm trying to run a pairwise function between two specific phenotypes' measurements, but am lost on how to tell R to look at the "Phenotype_Measurement" contingently to the "Phenotype column."

My best guess is this:

pairs(ThermalVar,Phenotype%in% = c(1Week-AcclimationSurvival_NegativeSixDegreesC_F, 1Week-Non-acclimationSurvival_NegativeSixDegreesC_F),
pch = 21,
bg = rainbow(2))

Hugely grateful for any help!

1

There are 1 best solutions below

0
guasi On

Are you looking to filter? The question is unclear. The following will filter conditions where Phenotype is equal to any of the values in the vector, where pch is 12, and bg is equal to the result of rainbow(2).

library(dplyr)

ThermalVar %>% 
  filter(Phenotype %in% c("1Week-AcclimationSurvival_NegativeSixDegreesC_F", 
                          "1Week-Non-acclimationSurvival_NegativeSixDegreesC_F"),
          pch == 21,
          bg == rainbow(2))