Help on plotting in R

r

#1

Hi Team,

I am very new to R and i need help to find a solution. I have the below timeseries dataset and i want to plot various companies as a line vs date with companies as legend and in different colours. Below is the header of the dataset. The date 1 column is changed by using as.date function. the last column is modified using as.date function since Date column is stored as Factor in the data frame. Please help!

I am able to plot in various colours so far for 5 companies using the below command however i dont know how to give legends in ggplot for all the companies like compA to CompJ should be the legends in the plot.

ggplot(data=My_Stockdata1)+geom_point(mapping = aes(x=Date1,y=CompA),colour=“red”)+geom_point(mapping = aes(x=Date1,y=CompB),colour=“green”)+geom_point(mapping = aes(x=Date1,y=CompC),colour=“blue”)+geom_point(mapping = aes(x=Date1,y=CompD),colour=“brown”)+geom_point(mapping = aes(x=Date1,y=CompE),colour=“yellow”)

Date CompA CompB CompC CompD CompE CompF CompG CompH CompI CompJ Date1
4-Jan-88 17.219 50.5 18.75 43 60.875 26.375 67.75 19 48.75 34.875 1/4/1988
5-Jan-88 17.891 51.375 19.625 44 62 26.125 68.125 19.125 48.75 35.625 1/5/1988
6-Jan-88 18.438 50.875 19.875 43.875 61.875 27.25 68.5 18.25 49 36.375 1/6/1988
7-Jan-88 18.672 51.5 20 44 62.625 27.875 69.375 18.375 49.625 36.25 1/7/1988
8-Jan-88 17.438 49 20 41.375 59.75 25.875 63.25 16.5 47.5 35.5 1/8/1988
11-Jan-88 18.109 49 19.5 41.875 59.625 26.625 66.25 17.125 47.75 34.375 1/11/1988
12-Jan-88 18.563 49.375 19.125 42.5 60.75 27.25 65.75 16.875 47.875 34 1/12/1988
13-Jan-88 18.672 50.125 19.25 43 61.75 28 66 16.875 47.25 34.625 1/13/1988
14-Jan-88 18.563 49.75 19 43.25 61.75 29 65.75 17.125 47 34.875 1/14/1988