How to summarize(add) a column according to same year and plot in R?
Step 1: Changing dates to years

First you can change your column of dates (Order_Date) to simply years by using this formula:

&gt; salesdata$Order_Date = format(salesdata$Order_Date, "%Y")


This will give your Order Dates just the year the sales was done in.

Step 2: Summarizing your sales data

After this you can create a vector with the summarizations of your sales data per year. This can be done using tapply:

&gt; tapply(salesdata$Sales, salesdata$Order_Date, FUN=sum)


This will give you an overview of the total sales per year.

Step 3: Plotting your graph

You can use barplot() to plot your bar chart using the values you got in your tapply function.

One-liner

The function as a oneliner:

&gt; barplot(tapply(salesdata$Sales, format(salesdata$Order_Date, "%Y"), FUN=sum))


Of course you can edit your graph to your liking.