๐ŸŒ Week 3 Homework โ€” Feedback

Student: Sofia Bruga
Files: week3_homework_starter.m, WB_RGDP.csv
Assignment: World Bank Real GDP & Growth (CSV version)


โš ๏ธ Overall Assessment

Result: โš ๏ธ Partially correct

The submission contains the script and a CSV, but the code does not run end-to-end due to an import/parsing error and a fragile filename split. After copying the CSV into the main folder, execution stops with:

Index exceeds the number of array elements. Index must not exceed 1.
Error in week3_homework_starter (line 41)
country_name = split_name{4};

Also, the CSV was placed in an Inout/ folder (typo) and not referenced correctly by the script.


๐Ÿ” Whatโ€™s going wrong

1) Header not parsed; all data in one โ€œmegaโ€ column
Your preview shows a single variable named like
CountryName__CountryCode___IndicatorName___IndicatorCode___1960___...
This means readtable did not detect the header/delimiter correctly.

2) Fragile filename parsing
country_name = split_name{4}; assumes the filename contains at least 4 โ€œ_โ€ tokens. It fails when that isnโ€™t true. You shouldnโ€™t read country names from the filename anywayโ€”use the table columns.

3) Non-reproducible path
CSV location (Inout/) doesnโ€™t match the path in the code.


๐Ÿ”ง Task-by-Task Check

Task Description Status Notes
1 Import WB real GDP CSV โŒ Wrong import options; header/delimiter not detected.
2 Extract (country/iso3, year, value) โŒ Blocked by import issue.
3 Build tidy long panel โŒ Not reached.
4 Compute logs & annual growth โŒ Not reached.
5 Verify US growth โŒ No plot.
6 Levels plot + legend โŒ Not produced.
7 Growth subplots + mean line โŒ Not produced.
8 Export panel CSV โŒ Not produced.

โœ… Minimal fixes (match the reference CSV solution)

A) Robust import (header + delimiter)

fname = 'WB_RGDP.csv';             % place the CSV in the same folder as the script
opts = detectImportOptions(fname, 'Delimiter', ',');
opts.VariableNamesLine = 1;        % header row
% If your file has metadata rows, uncomment the next line and adjust:
% opts.DataLines = [2, Inf];
T = readtable(fname, opts);

For the rest see solution files.