In order to add a file to this notebook, click the paperclip icon on the right side of the web page. After that, click the '+' icon next to the bolded File attachments line.
This creates a feature class from the polygons in the .json file you just added.
Within the parentheses, it is (FILE VARIABLE, directory to specific array)
- The variable we are looking in is MI_Counties
- The features we are extracting are in MI_Counties > objects > MI_Counties
This extracts the specific csv data you are interested in from your attached csv file.
d3.csvParse extracts the data and after the => is what you want to do with the data.
- d3.csvParse(await FileAttachment("MI_FoodIns.csv").text(),({FIPS, TractSNAP, Pop2010})
adds the columns FIPS, TractsSNAP, and Pop2010 to the code.
- [FIPS, +TractSNAP/+Pop2010])
uses the columns you imported to create new columns/arrays within your codes dataset.
This creates objects for the data you created.
On top of bringing in the data like the last step, there is an additional section:
(({FIPS, TractSNAP, Pop2010}) => ({FIPS: +FIPS, pctSNAP: +TractSNAP/+Pop2010}))
This assigns a name to each of the values you created.
FIPS for the FIPS code. pctSNAP for the TractSNAP/Pop2010 variable.
This is the bar graph of the data. It is counting the number of variables on the x-axis that fit within certain bins (a range) within the graph.
- Plot.binX({y: "count"}
Creates a count on the y axis for...
- {x: "pctSNAP",
The pct of population qualifying for SNAP benefits on the X axis within...
-thresholds: bins})),
The set range of each datapoint
COMMENT ON HISTOGRAM:
This histogram is heavily skewed towards zero. This is because of a single outlier that has 2.5% of the census block's population on SNAP benefits.
This outlier will heavily skew my scales.
- The unclassed scheme from Min - Max creates a very light-colored data set other than the highest value
- In the quantile classification, it creates the illusion that there are a higher amount of census blocks with a higher percentage of SNAP users than there actually are.
- The natural breaks classification creates an understandable dataset, with the outlier(s) highlighted.
- In the equal interval because the outlier skews the data so much, the split down the middle of the data divides the classes into non-outliers and the outlier. The outlier skews the data so much, the middle class of the three has no values in it.
- For threshold I was able to choose my own values, they split the 'normal' data well and isolate the outlier as well.
creates an easily understandable array from our CSV data that we imported.
- d => d[1]
creates a single array from the specific nested array we want "pctSNAP"
This creates a function from our created array and uses a quantile classification. Each color code ["#e0f3db", "#a8ddb5", "#43a2ca"] corresponds with a different range of the data.
This creates a function using the original array we created.
The domain is created with the minimum and maximum values of the array
- .domain([d3.min(pctSNAP),d3.max(pctSNAP)])
The range is set by the number of colors you provide, in this case, it is three.
This creates a graph of our created array and sections it off into user-created groups.
In this example, the groups are divided between 0.02, 0.4, and 2.5
HISTOGRAM COMMENT: The histogram of this data set is heavily skewed toward zero with one outlier at 2.5%. This is because there is a very small percentage of people that qualify for SNAP benefits. The one outlier may be a census block that has a relatively high rate of poverty.