[Solved] Code needed to convert call variable to two separate variables


This is how I would do it:

data = data.frame(
    Well = c("A01", "A02", "A03", "A04", "A05", "A06", "A07", "A08"),
    Call = c("No Call", "No Call", "Allele 1", "Heterozygote", "Allele 1",
             "Allele 2", "Heterozygote", "Heterozygote"),
    stringsAsFactors=FALSE
)
g121map = c("No Call"="", "Allele 1"="+", "Allele 2"="G1^{1384M}",
            "Heterozygote"="G1^{1384M}")
g122map = c("No Call"="", "Allele 1"="+", "Allele 2"="G1^{1384M}",
            "Heterozygote"="+")
data["G1-21"] = g121map[data$Call]
data["G1-22"] = g122map[data$Call]

The data frame will now look like this:

> data
  Well         Call      G1-21      G1-22
1  A01      No Call                      
2  A02      No Call                      
3  A03     Allele 1          +          +
4  A04 Heterozygote G1^{1384M}          +
5  A05     Allele 1          +          +
6  A06     Allele 2 G1^{1384M} G1^{1384M}
7  A07 Heterozygote G1^{1384M}          +
8  A08 Heterozygote G1^{1384M}          +

You can use the exponent formatting in plots.

solved Code needed to convert call variable to two separate variables