- Avocado prices
- Baby names
October 6 2022
In this case study we will be working with Avocado Prices data.
You can get the data from GitHub.
Let’s start with the raw data we have.
Create your scales and axes, mapping year to the x axis, and AveragePrice to the y axis.
For your marks, use symbol
and just map x and y to their respective variables.
We will use an aggregate
transform to calculate the mean
Average Price by year
transform: [ { type: "aggregate", groupby: ["year"], fields: ["AveragePrice"], ops: ["mean"], as: ["m"] } ]
We can use view.data("name")
in the JavaScript console
Your x scale is still year, but for y use the new mean variable you created in your data transform.
In addition to symbol, add a line
transform with the same data.
What is the best choice for scale here, starting at zero or starting at the lowest mean price?
We are going to be using from the US Social Security website that has been transformed for this case study and can be access as a csv file on GitHub