aa <- read.csv("http://blog.lib.umn.edu/wage0005/echinacea/Aphiddatasheetcorrected.csv") str(aa) head(aa) levels(aa$species) levels(aa$genotype) unique(aa[, c("species", "genotype")]) aa$plantId <- paste(aa$plantnumber, aa$species, sep="-") unique(aa$plantId) plot(aa$daycount, aa$aphidcount) with(aa[aa$species == "angustifolia",], points(daycount, aphidcount, pch =19, col= "purple")) with(aa[aa$species == "coreopsis palmata",], points(jitter(daycount), aphidcount, pch =19, col= "black")) with(aa[aa$species == "echinacea pallida",], points(jitter(daycount), aphidcount, pch =19, col= "pink")) with(aa[aa$species == "heliopsis helianthoides",], points(jitter(daycount), aphidcount, pch =19, col= "green")) plot(aa$daycount, aa$aphidcount) with(aa[aa$genotype == "between",], points(daycount, aphidcount, pch =19, col= "purple")) with(aa[aa$genotype == "within",], points(jitter(daycount), aphidcount, pch =19, col= "green")) with(aa[aa$genotype == "inbred",], points(jitter(daycount), aphidcount, pch =19, col= "red")) pla <- unique(aa$plantId) pla[1] for (i in 1:122){ plot(aa$daycount, aa$aphidcount) with(aa[aa$plantId == pla[i],], points(daycount, aphidcount, pch =19, col= "purple", type="b")) title(main= paste(pla[i], " ", unique(aa$genotype[aa$plantId == pla[i]]))) readline() } ################ pla2 <- unique(aa[,c("plantId","genotype")]) pla2$color <- "green" pla2$color[pla2$genotype==""] <- "white" pla2$color[pla2$genotype=="between"] <- "blue" pla2$color[pla2$genotype=="inbred"] <- "red" pla2 plot(aa$daycount, aa$aphidcount) for (i in 1:122){ with(aa[aa$plantId == pla2[i,1],], points(daycount, aphidcount, pch =19, col= pla2[i,3], type="b")) }