Help adding shapes and colors to points in a ggplot line plot

Hello, I am new to R studio and have been able to create a line graph that has two treatments with two different colors to differentiate them. Now I am going back to try and give the two treatments two different shapes and colors for their points, rather than the points being the same shape. However, any attempt to do so yields a different error, the most common ones being "Error Object object", "Discrete value supplied to a continuous scale", and "cannot add objects together". Any help would be much appreciated. Here is the code chunk in question.

## select subset
library(cowplot)
library(shiny)
myGenePlot <- function(dat = cpm_norm, gene = "Ceric.01G000100") {
  df1 <- dat %>% filter(GeneID==gene)
  gene_name = df1[1,1]
  {day8Rich <- (((df1[1,2]) + (df1[1,3]) + (df1[1,4])))
    Avgday8Rich <- ((day8Rich) / 3)}
  returnValue(Avgday8Rich)
  {day9Rich <- (((df1[1,5]) + (df1[1,6]) + (df1[1,7])))
    Avgday9Rich <- ((day9Rich) / 3)}
  returnValue(Avgday9Rich)
  {day10Rich <- (((df1[1,8]) + (df1[1,9]) + (df1[1,10])))
    Avgday10Rich <- ((day10Rich) / 3)}
  returnValue(Avgday10Rich)
  {day11Rich <- (((df1[1,11]) + (df1[1,12]) + (df1[1,13])))
    Avgday11Rich <- ((day11Rich) / 3)}
  returnValue(Avgday11Rich)
  {day12Rich <- (((df1[1,14]) + (df1[1,15]) + (df1[1,16])))
    Avgday12Rich <- ((day12Rich) / 3)}
  returnValue(Avgday12Rich)
  {day13Rich <- (((df1[1,17]) + (df1[1,18]) + (df1[1,19])))
    Avgday13Rich <- ((day13Rich) / 3)}
  returnValue(Avgday13Rich)
  {day8Basal <- (((df1[1,20]) + (df1[1,21]) + (df1[1,22])))
    Avgday8Basal <- ((day8Basal) / 3)}
  returnValue(Avgday8Basal)
  {day9Basal <- (((df1[1,23]) + (df1[1,24]) + (df1[1,25])))
    Avgday9Basal <- ((day9Basal) / 3)}
  returnValue(Avgday9Basal)
  {day10Basal <- (((df1[1,26]) + (df1[1,27]) + (df1[1,28])))
    Avgday10Basal <- ((day10Basal) / 3)}
  returnValue(Avgday10Basal)
  {day11Basal <- (((df1[1,29]) + (df1[1,30]) + (df1[1,31])))
    Avgday11Basal <- ((day11Basal) / 3)}
  returnValue(Avgday11Basal)
  {day12Basal <- (((df1[1,32]) + (df1[1,33]) + (df1[1,34])))
    Avgday12Basal <- ((day12Basal) / 3)}
  returnValue(Avgday12Basal)
  {day13Basal <- ((df1[1,35]) + (df1[1,36]) + (df1[1,37]))
    Avgday13Basal <- ((day13Basal) / 3)}
  returnValue(Avgday13Basal)
  sd_dfDay8B <- data.frame(Replicate = c(df1[1,2], df1[1,3], df1[1,4]),
                           Day = c(8, 8, 8))
  sd_Day8B <- sd(sd_dfDay8B$Replicate)
  sd_dfDay9B <- data.frame(Replicate = c(df1[1,5], df1[1,6], df1[1,7]),
                           Day = c(9, 9, 9))
  sd_Day9B <- sd(sd_dfDay9B$Replicate)
  sd_dfDay10B <- data.frame(Replicate = c(df1[1,8], df1[1,9], df1[1,10]),
                            Day = c(10, 10, 10))
  sd_Day10B <- sd(sd_dfDay10B$Replicate)
  sd_dfDay11B <- data.frame(Replicate = c(df1[1,11], df1[1,12], df1[1,13]),
                            Day = c(11, 11, 11))
  sd_Day11B <- sd(sd_dfDay11B$Replicate)
  sd_dfDay12B <- data.frame(Replicate = c(df1[1,14], df1[1,15], df1[1, 16]),
                            Day = c(12, 12, 12))
  sd_Day12B <- sd(sd_dfDay12B$Replicate)
  sd_dfDay13B <- data.frame(Replicate = c(df1[1,17], df1[1,18], df1[1, 19]),
                            Day = c(13, 13, 13))
  sd_Day13B <- sd(sd_dfDay13B$Replicate)
  sd_dfDay8R <- data.frame(Replicate = c(df1[1,20], df1[1,21], df1[1, 22]),
                           Day = c(8, 8, 8))
  sd_Day8R <- sd(sd_dfDay8R$Replicate)
  sd_dfDay9R <- data.frame(Replicate = c(df1[1,23], df1[1,24], df1[1, 25]),
                           Day = c(9, 9, 9))
  sd_Day9R <- sd(sd_dfDay9R$Replicate)
  sd_dfDay10R <- data.frame(Replicate = c(df1[1,26], df1[1,27], df1[1, 28]),
                            Day = c(10, 10, 10))
  sd_Day10R <- sd(sd_dfDay10R$Replicate)
  sd_dfDay11R <- data.frame(Replicate = c(df1[1,29], df1[1,30], df1[1, 31]),
                            Day = c(11, 11, 11))
  sd_Day11R <- sd(sd_dfDay11R$Replicate)
  sd_dfDay12R <- data.frame(Replicate = c(df1[1,32], df1[1,33], df1[1, 34]),
                            Day = c(12, 12, 12))
  sd_Day12R <- sd(sd_dfDay12R$Replicate)
  sd_dfDay13R <- data.frame(Replicate = c(df1[1,35], df1[1,36], df1[1, 37]),
                            Day = c(13, 13, 13))
  sd_Day13R <- sd(sd_dfDay13R$Replicate)
  Main_df <- data.frame(Avg.rpm = c(Avgday8Basal, Avgday9Basal, Avgday10Basal, Avgday11Basal, Avgday12Basal, Avgday13Basal, Avgday8Rich, Avgday9Rich, Avgday10Rich, Avgday11Rich, Avgday12Rich, Avgday13Rich),
                        Day = c(8, 9, 10, 11, 12, 13, 8, 9, 10, 11, 12, 13),
                        Media = c("Basal", "Basal", "Basal", "Basal", "Basal", "Basal", "Rich", "Rich", "Rich", "Rich", "Rich", "Rich"))
  sd <- c(sd_Day8B, sd_Day9B, sd_Day10B, sd_Day11B, sd_Day12B, sd_Day13B, sd_Day8R, sd_Day9R, sd_Day10R, sd_Day11R, sd_Day12R, sd_Day13R)
  ggplot(Main_df, mapping=aes(x=Day, y=Avg.rpm, colour=Media, group=Media)) +
    geom_errorbar(
      aes(ymin = Avg.rpm - sd, ymax = Avg.rpm + sd),
      width = .25,
      linewidth = 0.5,
      color = c("salmon1", "salmon1", "salmon1", "salmon1", "salmon1", "salmon1", "turquoise2", "turquoise2", "turquoise2", "turquoise2", "turquoise2", "turquoise2")) +
    geom_point(aes(color = "salmon","salmon", "salmon", "salmon", "salmon", "salmon", "turquoise3", "turquoise3", "turquoise3", "turquoise3", "turquoise3", "turquoise3")) +
    aes(color=Media)
}

This topic was automatically closed 21 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.