Q:

ggplot r: How to Highlight the Data from a Year

Data: Height was recorded daily
I want to plot the Height of my Plants (Plant A1 - Z50)
in single Plots, and i want to Highlight the current Year.
So i made a Subset of each Plant and a subset for the current year (2018)
Now i need a Plot with the total record an the highlighted Data from 2018
 dput(Plant)
structure(list(Name = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 
3L, 3L, 3L), .Label = c("Plant A1", "Plant B1", "Plant C1"), class = "factor"), 
    Date = structure(c(1L, 4L, 5L, 7L, 1L, 4L, 6L, 1L, 2L, 3L
    ), .Label = c("    2001-01-01", "    2001-01-02", "    2001-01-03", 
    "    2002-01-01", "    2002-02-01", "    2019-01-01", "    2019-12-31"
    ), class = "factor"), Height_cm = c(91, 106.1, 107.4, 145.9, 
    169.1, 192.1, 217.4, 139.8, 140.3, 140.3)), .Names = c("Name", 
"Date", "Height_cm"), class = "data.frame", row.names = c(NA, 
-10L))

Plant_A1 <- filter(Plant, Name == "Plant A1")
Current_Year <- as.numeric("2018")
Plant_A1_Subset <- filter(Plant_A1, format(Plant_A1$Date, '%Y') == Current_Year)

ggplot(data=Plant_A1,aes(x=Plant_A1$Date, y=Plant_A1$Heigth)) + 
  geom_point() + 
  geom_smooth(method="loes", level=0.95, span=1/2, color="red") +
  labs(x="Data", y="Height cm")

Now i don't know how to put my new Subset for 2018(Plant_A1_Subset) into this graph.

A:

As noted, this question has a duplicate with an answer in this question.
That said here's likely the most common way of handling your problem.
In ggplot2 future calls inherits any arguments passed into aes of the ggplot(aes(...)) function. Thus the plot will always use these arguments in future ggplot functions, unless one manually overwrites the arguments. However we can solve your problem, by simply adding an extra argument in the aes of geom_point. Below I've illustrated a simple way to achieve what you might be looking for.
Specify the aes argument in individual calls
The first method is likely the most intuitive. aes controls the the plotted parameters. As such if you want to add colour to certain points, one way is to let the aes be individual to the geom_point and geom_smooth argument.
library(ggplot2)
library(lubridate) #for month(), year(), day() functions
current_year <- 2018
ggplot(data = Plant_A1, aes(x = Date, y = Heigth)) +
    #Note here, colour set in geom_point
    geom_point(aes(col = ifelse(year(Date) == current_year, "Yes", "No"))) + 
    geom_smooth(method="loess", level=0.95, 
                span=1/2, color="red") +
    labs(x="Data", y="Height cm",
         col = "Current year?") #Specify legend title for colour

Note here that i have used the inheritance of the aes argument. Simply put, the aes will check the names within data, and if it can find it, it will use these as variables. So there is no need to specify data$....

