DA Homework 3

Task 0

Download the purchases.csv from the data section. This sample data contains purchases from an online store. Load the data into R and check whether the type of your variables are correct (e.g. purchase_date should be of type “Date”).

## Error: '/Users/jdivenyi/teaching/BME_adat/201617/data/purchases.csv' does not exist.

Task 1

Plot the histogram of all the log sales.

## Error in eval(lhs, parent, parent): object 'purchases' not found

Task 2

Plot the distributions of log sales amounts for the two years separately. Check geom_density in the documentation of ggplot2. Here is what you should get.

## Error in eval(lhs, parent, parent): object 'purchases' not found

Task 3

Plot the aggregate daily sales. Add a smoothed line to the plot (you can experiment with the span option of geom_smooth() to control the smoothness of your line).

Default:

## Error in eval(lhs, parent, parent): object 'purchases' not found

With span = 0.2:

## Error in eval(lhs, parent, parent): object 'purchases' not found

Task 4

Which month brings the most sales? Plot a bar graph with aggregate sales per month. Look at the documentation of geom_bar() to solve this. Note the labels of the x axis (the documentation helps to reproduce).

## Error in eval(lhs, parent, parent): object 'purchases' not found

Task 5

Recreate the previous graph by drawing the columns separately for the years (map the year variable to the fill of the bars and see the examples in the documentation to achieve side-by-side bars).

## Error in eval(lhs, parent, parent): object 'purchases' not found

Task 6

We have seen that the aggregate sales are lower in 2013 than in 2012. Which year has higher average sales amount? Plot a bar graph with average sales per year and add error bars with two times the standard deviation (do not forget to adjust by the number of observations). You can add error bars by using the geom_errorbar() function of ggplot2. (I use the “lightblue” color to fill the bars in order to make the error bars more visible.)

## Error in eval(lhs, parent, parent): object 'purchases' not found

Task +1

Watch this video and collect 3 positive (or negative) points about the presentation.