Steps for Completion:
- Use the strftime command to get the month from each date and make another variable (Month), as follows:
df_fb$Month <- strftime(df_fb$Date,"%m")
- Change the month to a numerical value by using as.numeric:
df_fb$Month <- as.numeric(df_fb$Month)
- Now, use ggplot to make a plot of closing prices versus months.
- Plot the data using geom_point (color=red).
- Change the x scale to show each month, and label the x-axis, such that each month is shown.
- Title your plot Monthly closing stock prices: Facebook.
- Use geom_line(stat='summary',fun.y=mean) to plot the mean.
Outcome:
The complete code is shown as follows:
ggplot(df_fb, aes(Month,Close)) + geom_point(color="red",alpha=1/2,position ...