Main Content

Grouped Calculations in Tables and Timetables

Grouped calculations can help you interpret large datasets such as time-series data. In such calculations, you use a grouping variable to split a dataset into groups and apply a function to each group. A grouping variable contains values, such as time periods or station locations, that you can use to group other data values, such as temperature readings or atmospheric concentrations of a gas. In MATLAB®, you can store such data in tables or timetables. With grouped calculations in a table you can often calculate results in-place, in one table, instead of breaking data out into separate tables and merging results later.

This example shows how to import nitrogen dioxide (NO2) data from the US Environmental Protection Agency (EPA) into a table and do grouped calculations on this data. NO2 is one of the Criteria Air Pollutants regulated under the US Clean Air Act. It is toxic by itself and is also a key component of photochemical smog that results in ground-level ozone production. NO2 is produced through high-temperature processes that can split nitrogen and oxygen gases and enable them to recombine. Natural processes contribute NO2 to the atmosphere, but so do human activities such as combustion in automobile engines and power plants, lightning, and biomass burning. The concentration of NO2 in the atmosphere is also influenced by the photochemical cycling between NO and NO2, atmospheric transport, and ultimately oxidation to nitric acid, causing acid rain. Different processes contribute NO2 to the atmosphere on different timescales, leading to daily (diurnal), weekly, and annual cycles in its atmospheric concentration. Time-series analysis of such data relies heavily on grouped calculations to examine different periodic behavior or to average the data over time to smooth out high-frequency variability and reveal long-term trends.

The example first shows how to do preliminary data cleaning, including conversion of the table to a timetable. Then it shows simple ways to group the data by one grouping variable and calculate annual mean NO2 concentrations. It also shows how to group the NO2 data by two grouping variables together, time and location, enabling calculations that find locations exceeding EPA standards at various times. You can also group the NO2 data by time period to look for daily or yearly cycles. Finally it shows how to apply a function that requires inputs from multiple table variables to find the times at which the maximum NO2 concentrations occurred at each site.

Import NO2 Data to Table

First, import NO2 data from the Air Quality System (AQS) database maintained by the EPA. This data consists of hourly measurements of NO2 concentrations from outdoor monitors across the United States, Puerto Rico, and the U.S. Virgin Islands. It is stored as a set of zipped spreadsheets, one for each year starting with 1980.

Download hourly NO2 measurements for the years 1985–1989. You can download and unzip the compressed spreadsheets by using the unzip function. The result is set of files in your current folder with names such as hourly_42602_1985.csv. Here, 42602 is an EPA code for NO2. (Data from the US Environmental Protection Agency. Air Quality System Data Mart available via Air Data: Air Quality Data Collected at Outdoor Monitors Across the US. Accessed July 15, 2021.)

yrs = string(1985:1989);
urls = "https://aqs.epa.gov/aqsweb/airdata/hourly_42602_" + yrs + ".zip";
fnames = strings(numel(yrs),1);
for ii = 1:numel(yrs)
    fnames(ii) = unzip(urls(ii));
end
fnames
fnames = 5×1 string
    "hourly_42602_1985.csv"
    "hourly_42602_1986.csv"
    "hourly_42602_1987.csv"
    "hourly_42602_1988.csv"
    "hourly_42602_1989.csv"

Import data from the spreadsheets into a table. Start by creating an empty table. Then import data from the spreadsheets, one by one, by using the readtable function and adding it to the table.

Create import options that help specify how readtable imports tabular data. To create import options based on the contents of the spreadsheets, use the detectImportOptions function. Read all the text data into table variables that store strings. You can also specify that only specified table variables have certain data types. To specify that only the TimeGMT and TimeLocal table variables store times as duration arrays, use the setvaropts function.

NO2data = table;
opts = detectImportOptions(fnames(1),"TextType","string");
opts = setvaropts(opts,["TimeGMT","TimeLocal"],"Type","duration","InputFormat","hh:mm");

Import data from the spreadsheets by using the readtable function. You can vertically concatenate the tables you read in so that all the data is in one large table.

The spreadsheets have column names, such as "Time GMT", that you cannot use as MATLAB identifiers. As the warning messages indicate, readtable converts these names into table variable names that are valid MATLAB identifiers, such as TimeGMT. When a table variable name is also a valid MATLAB identifier, it is easier to access the variable by using dot notation, as in NO2data.TimeGMT.

for ii = 1:numel(yrs)
    NO2data = [NO2data; readtable(fnames(ii),opts)];
end
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating variable names for the table. The original column headers are saved in the VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating variable names for the table. The original column headers are saved in the VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating variable names for the table. The original column headers are saved in the VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating variable names for the table. The original column headers are saved in the VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating variable names for the table. The original column headers are saved in the VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.

Display NO2data. It has 24 variables storing NO2 sample measurements, site locations, state names, times, and many other pieces of information.

NO2data
NO2data=11294497×24 table
    StateCode    CountyCode    SiteNum    ParameterCode    POC    Latitude    Longitude     Datum          ParameterName           DateLocal     TimeLocal      DateGMT      TimeGMT    SampleMeasurement      UnitsOfMeasure       MDL    Uncertainty    Qualifier    MethodType    MethodCode                MethodName                StateName    CountyName    DateOfLastChange
    _________    __________    _______    _____________    ___    ________    _________    _______    ________________________    ___________    _________    ___________    _______    _________________    ___________________    ___    ___________    _________    __________    __________    __________________________________    _________    __________    ________________

        4            1            7           42602         1      34.128      -109.31     "WGS84"    "Nitrogen dioxide (NO2)"    02-Jan-1985      01:00      02-Jan-1985     08:00             0            "Parts per billion"     5         ""            ""        "Non-FRM"         14        "INSTRUMENTAL - CHEMILUMINESCENCE"    "Arizona"     "Apache"            ""       
        4            1            7           42602         1      34.128      -109.31     "WGS84"    "Nitrogen dioxide (NO2)"    02-Jan-1985      02:00      02-Jan-1985     09:00             0            "Parts per billion"     5         ""            ""        "Non-FRM"         14        "INSTRUMENTAL - CHEMILUMINESCENCE"    "Arizona"     "Apache"            ""       
        4            1            7           42602         1      34.128      -109.31     "WGS84"    "Nitrogen dioxide (NO2)"    02-Jan-1985      03:00      02-Jan-1985     10:00             0            "Parts per billion"     5         ""            ""        "Non-FRM"         14        "INSTRUMENTAL - CHEMILUMINESCENCE"    "Arizona"     "Apache"            ""       
        4            1            7           42602         1      34.128      -109.31     "WGS84"    "Nitrogen dioxide (NO2)"    02-Jan-1985      04:00      02-Jan-1985     11:00             0            "Parts per billion"     5         ""            ""        "Non-FRM"         14        "INSTRUMENTAL - CHEMILUMINESCENCE"    "Arizona"     "Apache"            ""       
        4            1            7           42602         1      34.128      -109.31     "WGS84"    "Nitrogen dioxide (NO2)"    02-Jan-1985      05:00      02-Jan-1985     12:00             0            "Parts per billion"     5         ""            ""        "Non-FRM"         14        "INSTRUMENTAL - CHEMILUMINESCENCE"    "Arizona"     "Apache"            ""       
        4            1            7           42602         1      34.128      -109.31     "WGS84"    "Nitrogen dioxide (NO2)"    02-Jan-1985      06:00      02-Jan-1985     13:00             0            "Parts per billion"     5         ""            ""        "Non-FRM"         14        "INSTRUMENTAL - CHEMILUMINESCENCE"    "Arizona"     "Apache"            ""       
        4            1            7           42602         1      34.128      -109.31     "WGS84"    "Nitrogen dioxide (NO2)"    02-Jan-1985      08:00      02-Jan-1985     15:00             0            "Parts per billion"     5         ""            ""        "Non-FRM"         14        "INSTRUMENTAL - CHEMILUMINESCENCE"    "Arizona"     "Apache"            ""       
        4            1            7           42602         1      34.128      -109.31     "WGS84"    "Nitrogen dioxide (NO2)"    02-Jan-1985      09:00      02-Jan-1985     16:00             0            "Parts per billion"     5         ""            ""        "Non-FRM"         14        "INSTRUMENTAL - CHEMILUMINESCENCE"    "Arizona"     "Apache"            ""       
        4            1            7           42602         1      34.128      -109.31     "WGS84"    "Nitrogen dioxide (NO2)"    02-Jan-1985      10:00      02-Jan-1985     17:00             0            "Parts per billion"     5         ""            ""        "Non-FRM"         14        "INSTRUMENTAL - CHEMILUMINESCENCE"    "Arizona"     "Apache"            ""       
        4            1            7           42602         1      34.128      -109.31     "WGS84"    "Nitrogen dioxide (NO2)"    02-Jan-1985      16:00      02-Jan-1985     23:00             1            "Parts per billion"     5         ""            ""        "Non-FRM"         14        "INSTRUMENTAL - CHEMILUMINESCENCE"    "Arizona"     "Apache"            ""       
        4            1            7           42602         1      34.128      -109.31     "WGS84"    "Nitrogen dioxide (NO2)"    02-Jan-1985      17:00      03-Jan-1985     00:00             1            "Parts per billion"     5         ""            ""        "Non-FRM"         14        "INSTRUMENTAL - CHEMILUMINESCENCE"    "Arizona"     "Apache"            ""       
        4            1            7           42602         1      34.128      -109.31     "WGS84"    "Nitrogen dioxide (NO2)"    02-Jan-1985      18:00      03-Jan-1985     01:00             1            "Parts per billion"     5         ""            ""        "Non-FRM"         14        "INSTRUMENTAL - CHEMILUMINESCENCE"    "Arizona"     "Apache"            ""       
        4            1            7           42602         1      34.128      -109.31     "WGS84"    "Nitrogen dioxide (NO2)"    02-Jan-1985      19:00      03-Jan-1985     02:00             0            "Parts per billion"     5         ""            ""        "Non-FRM"         14        "INSTRUMENTAL - CHEMILUMINESCENCE"    "Arizona"     "Apache"            ""       
        4            1            7           42602         1      34.128      -109.31     "WGS84"    "Nitrogen dioxide (NO2)"    02-Jan-1985      20:00      03-Jan-1985     03:00             0            "Parts per billion"     5         ""            ""        "Non-FRM"         14        "INSTRUMENTAL - CHEMILUMINESCENCE"    "Arizona"     "Apache"            ""       
        4            1            7           42602         1      34.128      -109.31     "WGS84"    "Nitrogen dioxide (NO2)"    02-Jan-1985      21:00      03-Jan-1985     04:00             0            "Parts per billion"     5         ""            ""        "Non-FRM"         14        "INSTRUMENTAL - CHEMILUMINESCENCE"    "Arizona"     "Apache"            ""       
        4            1            7           42602         1      34.128      -109.31     "WGS84"    "Nitrogen dioxide (NO2)"    02-Jan-1985      22:00      03-Jan-1985     05:00             0            "Parts per billion"     5         ""            ""        "Non-FRM"         14        "INSTRUMENTAL - CHEMILUMINESCENCE"    "Arizona"     "Apache"            ""       
      ⋮

Clean NO2 Table and Convert to Timetable

Next, prepare NO2data for analysis by cleaning the data. Data cleaning is the process of detecting and correcting (or removing) parts of the data set that are either corrupt, inaccurate, or irrelevant. You can also convert table variables so that they have data types that can be more convenient for analysis, such as categorical or datetime arrays.

For example, the table variable SampleMeasurement has measurements of NO2 concentration. Concentrations below the method detection limit (MDL) are unreliable. To exclude them from analysis, find the rows where SampleMeasurement is below the MDL. Set those elements to NaN.

NO2data.SampleMeasurement(NO2data.SampleMeasurement < NO2data.MDL) = NaN;

Create a table that contains only the subset of variables that are relevant to this example. You can use table subscripting to create a table that has all rows (specified by a colon) and only those variables that you name.

NO2data = NO2data(:,["DateLocal","TimeLocal","SampleMeasurement","StateName","CountyName","SiteNum","Latitude","Longitude"])
NO2data=11294497×8 table
     DateLocal     TimeLocal    SampleMeasurement    StateName    CountyName    SiteNum    Latitude    Longitude
    ___________    _________    _________________    _________    __________    _______    ________    _________

    02-Jan-1985      01:00             NaN           "Arizona"     "Apache"        7        34.128      -109.31 
    02-Jan-1985      02:00             NaN           "Arizona"     "Apache"        7        34.128      -109.31 
    02-Jan-1985      03:00             NaN           "Arizona"     "Apache"        7        34.128      -109.31 
    02-Jan-1985      04:00             NaN           "Arizona"     "Apache"        7        34.128      -109.31 
    02-Jan-1985      05:00             NaN           "Arizona"     "Apache"        7        34.128      -109.31 
    02-Jan-1985      06:00             NaN           "Arizona"     "Apache"        7        34.128      -109.31 
    02-Jan-1985      08:00             NaN           "Arizona"     "Apache"        7        34.128      -109.31 
    02-Jan-1985      09:00             NaN           "Arizona"     "Apache"        7        34.128      -109.31 
    02-Jan-1985      10:00             NaN           "Arizona"     "Apache"        7        34.128      -109.31 
    02-Jan-1985      16:00             NaN           "Arizona"     "Apache"        7        34.128      -109.31 
    02-Jan-1985      17:00             NaN           "Arizona"     "Apache"        7        34.128      -109.31 
    02-Jan-1985      18:00             NaN           "Arizona"     "Apache"        7        34.128      -109.31 
    02-Jan-1985      19:00             NaN           "Arizona"     "Apache"        7        34.128      -109.31 
    02-Jan-1985      20:00             NaN           "Arizona"     "Apache"        7        34.128      -109.31 
    02-Jan-1985      21:00             NaN           "Arizona"     "Apache"        7        34.128      -109.31 
    02-Jan-1985      22:00             NaN           "Arizona"     "Apache"        7        34.128      -109.31 
      ⋮

Combine the local date and time into a single timestamp. The new Timestamp table variable is a datetime array. Delete the DateLocal and TimeLocal variables because they are now redundant.

NO2data.Timestamp = NO2data.DateLocal + NO2data.TimeLocal;
NO2data.Timestamp.Format = "default";
NO2data.DateLocal = [];
NO2data.TimeLocal = [];

To categorize the data later, convert the StateName and CountyName variables to categorical arrays, first erasing space characters from the names. There are fixed sets of state and county names in the data, which makes it convenient to create categories based on them.

NO2data.StateName = categorical(erase(NO2data.StateName," "));
NO2data.CountyName = categorical(erase(NO2data.CountyName," "));

Rename the SampleMeasurement variable to MeasuredNO2. One way to rename table variables is by using the VariableNames property of the table.

NO2data.Properties.VariableNames("SampleMeasurement") = "MeasuredNO2";

Convert NO2data to a timetable. The datetime values in Timestamp are now row times that label the rows of the timetable. The dates and times of the original table were in separate variables. To put data like this data into a timetable, it is more convenient to import the data as a table, and then combine the separate date and time variables into one datetime variable. Then convert the modified table by using the table2timetable function.

NO2data = table2timetable(NO2data)
NO2data=11294497×6 timetable
         Timestamp          MeasuredNO2    StateName    CountyName    SiteNum    Latitude    Longitude
    ____________________    ___________    _________    __________    _______    ________    _________

    02-Jan-1985 01:00:00        NaN         Arizona       Apache         7        34.128      -109.31 
    02-Jan-1985 02:00:00        NaN         Arizona       Apache         7        34.128      -109.31 
    02-Jan-1985 03:00:00        NaN         Arizona       Apache         7        34.128      -109.31 
    02-Jan-1985 04:00:00        NaN         Arizona       Apache         7        34.128      -109.31 
    02-Jan-1985 05:00:00        NaN         Arizona       Apache         7        34.128      -109.31 
    02-Jan-1985 06:00:00        NaN         Arizona       Apache         7        34.128      -109.31 
    02-Jan-1985 08:00:00        NaN         Arizona       Apache         7        34.128      -109.31 
    02-Jan-1985 09:00:00        NaN         Arizona       Apache         7        34.128      -109.31 
    02-Jan-1985 10:00:00        NaN         Arizona       Apache         7        34.128      -109.31 
    02-Jan-1985 16:00:00        NaN         Arizona       Apache         7        34.128      -109.31 
    02-Jan-1985 17:00:00        NaN         Arizona       Apache         7        34.128      -109.31 
    02-Jan-1985 18:00:00        NaN         Arizona       Apache         7        34.128      -109.31 
    02-Jan-1985 19:00:00        NaN         Arizona       Apache         7        34.128      -109.31 
    02-Jan-1985 20:00:00        NaN         Arizona       Apache         7        34.128      -109.31 
    02-Jan-1985 21:00:00        NaN         Arizona       Apache         7        34.128      -109.31 
    02-Jan-1985 22:00:00        NaN         Arizona       Apache         7        34.128      -109.31 
      ⋮

Simple Grouped Calculations by State

Given the size of the timetable, it is obvious that there are many thousands of hourly measurements in every state. One way to calculate the number of measurements for each state is to sum the number of rows that have a particular state as a category. For example, calculate the number of measurements for Alaska, and then for Arizona.

numAlaska = sum(NO2data.StateName=="Alaska")
numAlaska = 7071
numArizona = sum(NO2data.StateName=="Arizona")
numArizona = 142793

It is tedious to perform this calculation multiple times or to store intermediate results in many variables or subtables. Instead, MATLAB provides functions that group data in tables and apply functions to each group in-place. For example, use the groupcounts function to group the data in NO2data by the states in StateName and count the rows in each group. Instead of calling sum many times, call groupcounts once.

NO2counts = groupcounts(NO2data,"StateName")
NO2counts=42×3 table
        StateName         GroupCount    Percent 
    __________________    __________    ________

    Alaska                      7071    0.062606
    Arizona               1.4279e+05      1.2643
    Arkansas                   40723     0.36056
    California            3.4015e+06      30.116
    Colorado              2.2394e+05      1.9827
    Connecticut           1.2615e+05      1.1169
    Delaware                   75185     0.66568
    DistrictOfColumbia         74988     0.66393
    Florida               2.1172e+05      1.8746
    Georgia                    74971     0.66378
    Illinois               4.407e+05      3.9019
    Indiana               3.3058e+05       2.927
    Kansas                     10625    0.094072
    Kentucky              2.8789e+05       2.549
    Louisiana             1.6914e+05      1.4976
    Maryland              1.2565e+05      1.1125
      ⋮

To sort the results in a table or timetable, use the sortrows function. Sort gc on its GroupCount variable from highest to lowest value.

sortedNO2counts = sortrows(NO2counts,"GroupCount","descend")
sortedNO2counts=42×3 table
      StateName      GroupCount    Percent
    _____________    __________    _______

    California       3.4015e+06    30.116 
    Pennsylvania     8.2796e+05    7.3307 
    Missouri         4.8609e+05    4.3038 
    Texas            4.7163e+05    4.1758 
    Illinois          4.407e+05    3.9019 
    Virginia         3.4464e+05    3.0514 
    Massachusetts    3.3833e+05    2.9956 
    Indiana          3.3058e+05     2.927 
    NewJersey        3.2862e+05    2.9095 
    Montana          2.8886e+05    2.5576 
    Kentucky         2.8789e+05     2.549 
    NorthDakota      2.7822e+05    2.4633 
    Ohio             2.7478e+05    2.4329 
    Oklahoma         2.4477e+05    2.1672 
    NewYork          2.3126e+05    2.0475 
    Wisconsin        2.3079e+05    2.0434 
      ⋮

To calculate other statistics, use the groupsummary function. For example, find the maximum NO2 concentration measured in each state.

NO2max = groupsummary(NO2data,"StateName","max","MeasuredNO2");
sortedNO2max = sortrows(NO2max,"max_MeasuredNO2","descend")
sortedNO2max=42×3 table
     StateName      GroupCount    max_MeasuredNO2
    ____________    __________    _______________

    Nevada               64821         743.5     
    California      3.4015e+06           540     
    Indiana         3.3058e+05           500     
    Colorado        2.2394e+05           462     
    NewYork         2.3126e+05           451     
    Tennessee       1.9592e+05           410     
    Ohio            2.7478e+05           403     
    Kentucky        2.8789e+05           368     
    Pennsylvania    8.2796e+05           357     
    Minnesota            90293           328     
    Missouri        4.8609e+05           326     
    Connecticut     1.2615e+05           319     
    Oklahoma        2.4477e+05           318     
    NewHampshire         25598           312     
    Delaware             75185           300     
    Louisiana       1.6914e+05           286     
      ⋮

As an alternative, you can use the varfun function with the "GroupingVariables" name-value argument for grouped calculations. But the groupsummary function is simpler and performs most of the same grouped calculations as varfun.

Simple Grouped Calculations by Time

Functions such as groupcounts, groupsummary, and varfun work equally well on tables and timetables. But timetables also provide the retime and synchronize functions, which can perform time-based calculations by using their row times. You can group timetable data by time and perform calculations on data within the time periods. The retime function is the best option for such cases.

For example, group the data in NO2data into yearly time periods. Find the maximum NO2 concentration for each year.

yearlyMaxNO2 = retime(NO2data(:,"MeasuredNO2"),"yearly","max")
yearlyMaxNO2=5×1 timetable
     Timestamp     MeasuredNO2
    ___________    ___________

    01-Jan-1985       407.3   
    01-Jan-1986         500   
    01-Jan-1987         497   
    01-Jan-1988       743.5   
    01-Jan-1989         462   

This calculation is useful if you have one time series. In this case, the data in the MeasuredNO2 variable come from multiple sites. A more useful analysis is to group by both year and site.

Calculate Annual Means by Site

The US EPA has two National Ambient Air Quality Standards (NAAQS) for NO2. A location is not in compliance with the NAAQS if either:

  • The annual mean exceeds 53 ppb

  • The 98th percentile of 1-hour daily maximum concentrations, averaged over 3 years, exceeds 100 parts-per-billion (ppb)

Analyze data in NO2data to find locations that are not in compliance with the first standard, where the annual mean exceeded 53 ppb. There are three different ways to approach this analysis. What the three approaches have in common is that you can group the data by both time and site to calculate annual means by site.

Group by Multiple Grouping Variables

To find sites that do not comply with the NAAQS, calculate the mean value for each site for each year. While NO2data does not include unique identifiers for the sites, you can use state names, county names, and site numbers together to uniquely identify air quality sites.

The row times of NO2data are datetime values. Extract their year components and add a new variable to NO2data named Year. Calculate the annual means for each site by using groupsummary with StateName, CountyName, SiteNum, and Year as grouping variables.

NO2data.Year = year(NO2data.Timestamp);
meanNO2bySite = groupsummary(NO2data,["StateName","CountyName","SiteNum","Year"],"mean","MeasuredNO2")
meanNO2bySite=1585×6 table
    StateName      CountyName      SiteNum    Year    GroupCount    mean_MeasuredNO2
    _________    ______________    _______    ____    __________    ________________

     Alaska      KenaiPeninsula     1004      1989       7071            9.7986     
     Arizona     Apache                7      1985       5920              7.75     
     Arizona     Apache                7      1986       2059            6.7857     
     Arizona     Apache                7      1988       1981            7.1391     
     Arizona     Apache                7      1989       3861            6.9146     
     Arizona     Apache                8      1985       6007            5.9138     
     Arizona     Apache                8      1986       1999            6.1875     
     Arizona     Apache                8      1988       1924            6.3333     
     Arizona     Apache                8      1989       3771            7.2619     
     Arizona     Apache                9      1985       5852            6.7021     
     Arizona     Apache                9      1986       1942            7.6579     
     Arizona     Apache                9      1988       2068            8.5333     
     Arizona     Apache                9      1989       3813            6.9604     
     Arizona     Apache               10      1985       5905            8.4406     
     Arizona     Apache               10      1986       2009            7.3333     
     Arizona     Apache               10      1988       2117            7.2381     
      ⋮

To find the sites that have the highest mean NO2, sort the timetable.

sortedMeanNO2bySite = sortrows(meanNO2bySite,"mean_MeasuredNO2","descend")
sortedMeanNO2bySite=1585×6 table
    StateName     CountyName    SiteNum    Year    GroupCount    mean_MeasuredNO2
    __________    __________    _______    ____    __________    ________________

    California    LosAngeles     1103      1988       8272            61.526     
    California    LosAngeles     1103      1986       8083            61.266     
    California    LosAngeles     1103      1985       8217            59.965     
    California    LosAngeles     1105      1985       1194            58.399     
    California    LosAngeles     1002      1986       8084            57.422     
    California    LosAngeles     1002      1985       8159            57.401     
    California    LosAngeles     1701      1989       8299            57.118     
    California    LosAngeles     1701      1986       8229            55.924     
    California    LosAngeles     1103      1989       8135            55.335     
    California    LosAngeles     1701      1987       8284            54.864     
    California    LosAngeles     1601      1989       8201            54.685     
    California    LosAngeles     1701      1985       8341            54.147     
    California    LosAngeles     1103      1987       8150            54.092     
    California    LosAngeles     1601      1988       7546            53.828     
    California    LosAngeles     1601      1985       8307            53.377     
    California    LosAngeles     2005      1989       8225            53.174     
      ⋮

You can create a table that includes only those sites exceeding 53 ppb by using logical indexing. Create a logical vector that indicates the rows where mean_MeasuredNO2 is greater than 53. Use that vector as a subscript to get matching rows from meanNO2bySite.

exceeded53ppb = meanNO2bySite.mean_MeasuredNO2 > 53;
sitesExceed53ppb = meanNO2bySite(exceeded53ppb,:)
sitesExceed53ppb=19×6 table
    StateName     CountyName    SiteNum    Year    GroupCount    mean_MeasuredNO2
    __________    __________    _______    ____    __________    ________________

    California    LosAngeles        2      1988       8278             53.17     
    California    LosAngeles     1002      1985       8159            57.401     
    California    LosAngeles     1002      1986       8084            57.422     
    California    LosAngeles     1002      1988       8176            53.004     
    California    LosAngeles     1103      1985       8217            59.965     
    California    LosAngeles     1103      1986       8083            61.266     
    California    LosAngeles     1103      1987       8150            54.092     
    California    LosAngeles     1103      1988       8272            61.526     
    California    LosAngeles     1103      1989       8135            55.335     
    California    LosAngeles     1105      1985       1194            58.399     
    California    LosAngeles     1601      1985       8307            53.377     
    California    LosAngeles     1601      1988       7546            53.828     
    California    LosAngeles     1601      1989       8201            54.685     
    California    LosAngeles     1701      1985       8341            54.147     
    California    LosAngeles     1701      1986       8229            55.924     
    California    LosAngeles     1701      1987       8284            54.864     
      ⋮

Pivot to Find Relationships Between Grouping Variables

Sometimes pivoting, or rearranging statistics calculated from tabular data, makes it easier to see and analyze results, particularly when you look at the relationship between two grouping variables. For example, you can create a pivot table for the annual mean NO2 by site. By pivoting, you can create a table where every site lists annual mean NO2 in its own table variable, showing the relationship between year and site. In MATLAB, you can create pivot tables by using the stack and unstack functions, which stack and unstack table variables into taller or wider formats.

A complication in this case is that NO2data has three grouping variables that together uniquely identify sites: state name, county name, and site number. To create a pivot table, first combine these three table variables into one variable. Convert StateName, CountyName, and SiteNum into strings and add them together. Replace spaces and dashes with underscores, and erase periods and parentheses. The names in SiteID are unique site identifiers.

siteID = string(NO2data.StateName) + "_" + string(NO2data.CountyName) + "_" + string(NO2data.SiteNum);
siteID = replace(siteID,[" ","-"],"_");
siteID = erase(siteID,[".","(",")"]);

Add SiteID to NO2data as a new table variable. Calculate annual means by using groupsummary, but this time use SiteID as a grouping variable.

NO2data.SiteID = categorical(siteID);
meanNO2bySiteID = groupsummary(NO2data,["SiteID","Year"],"mean","MeasuredNO2")
meanNO2bySiteID=1585×4 table
              SiteID              Year    GroupCount    mean_MeasuredNO2
    __________________________    ____    __________    ________________

    Alaska_KenaiPeninsula_1004    1989       7071            9.7986     
    Arizona_Apache_10             1985       5905            8.4406     
    Arizona_Apache_10             1986       2009            7.3333     
    Arizona_Apache_10             1988       2117            7.2381     
    Arizona_Apache_10             1989       4282            6.9929     
    Arizona_Apache_11             1985       5262            8.4264     
    Arizona_Apache_11             1986       1960             7.587     
    Arizona_Apache_11             1988       2063            8.0471     
    Arizona_Apache_11             1989       4266            7.5714     
    Arizona_Apache_7              1985       5920              7.75     
    Arizona_Apache_7              1986       2059            6.7857     
    Arizona_Apache_7              1988       1981            7.1391     
    Arizona_Apache_7              1989       3861            6.9146     
    Arizona_Apache_8              1985       6007            5.9138     
    Arizona_Apache_8              1986       1999            6.1875     
    Arizona_Apache_8              1988       1924            6.3333     
      ⋮

To create a pivot table, use the unstack function. Each unique site in the SiteID variable of meanNO2bySiteID becomes the name of a separate table variable in the output, pivotedMeanNO2bySiteID, and has the annual means associated with that site. This unstacking operation is how you can create a pivot table in MATLAB.

pivotedMeanNO2bySiteID = unstack(meanNO2bySiteID,"mean_MeasuredNO2","SiteID","GroupingVariable","Year")
pivotedMeanNO2bySiteID=5×443 table
    Year    Alaska_KenaiPeninsula_1004    Arizona_Apache_10    Arizona_Apache_11    Arizona_Apache_7    Arizona_Apache_8    Arizona_Apache_9    Arizona_Maricopa_3002    Arizona_Maricopa_3003    Arizona_Pima_1011    Arizona_Pima_19    Arizona_Pima_2    Arkansas_Pulaski_1002    California_Alameda_1001    California_Alameda_3    California_Butte_2    California_ContraCosta_1002    California_ContraCosta_2    California_ContraCosta_3    California_ContraCosta_3001    California_ElDorado_9    California_Fresno_241    California_Fresno_242    California_Fresno_5    California_Fresno_6    California_Fresno_7    California_Kern_232    California_Kern_4    California_Kern_5001    California_Kern_6    California_Kern_6001    California_Kern_7    California_LosAngeles_1002    California_LosAngeles_1103    California_LosAngeles_1105    California_LosAngeles_113    California_LosAngeles_1201    California_LosAngeles_1301    California_LosAngeles_16    California_LosAngeles_1601    California_LosAngeles_1701    California_LosAngeles_2    California_LosAngeles_2005    California_LosAngeles_2401    California_LosAngeles_4002    California_LosAngeles_4101    California_LosAngeles_5001    California_LosAngeles_6002    California_LosAngeles_7001    California_LosAngeles_8001    California_Marin_1    California_Mendocino_7    California_Monterey_1002    California_Napa_3    California_Orange_1    California_Orange_1002    California_Orange_5001    California_Plumas_1001    California_Riverside_5001    California_Riverside_6001    California_Riverside_8001    California_Sacramento_1    California_Sacramento_10    California_Sacramento_1001    California_Sacramento_2    California_Sacramento_5002    California_Sacramento_6    California_SanBernardino_1    California_SanBernardino_1004    California_SanBernardino_12    California_SanBernardino_2002    California_SanBernardino_3    California_SanBernardino_4001    California_SanBernardino_6    California_SanBernardino_7002    California_SanBernardino_9004    California_SanDiego_1    California_SanDiego_1002    California_SanDiego_1004    California_SanDiego_1006    California_SanDiego_1007    California_SanDiego_3    California_SanDiego_5    California_SanDiego_6    California_SanFrancisco_4    California_SanFrancisco_5    California_SanJoaquin_1002    California_SanLuisObispo_1004    California_SanLuisObispo_2001    California_SanLuisObispo_2002    California_SanLuisObispo_4001    California_SanMateo_1001    California_SantaBarbara_10    California_SantaBarbara_1010    California_SantaBarbara_1011    California_SantaBarbara_1012    California_SantaBarbara_1013    California_SantaBarbara_1014    California_SantaBarbara_1015    California_SantaBarbara_1016    California_SantaBarbara_1017    California_SantaBarbara_1018    California_SantaBarbara_1019    California_SantaBarbara_1020    California_SantaBarbara_1021    California_SantaBarbara_1025    California_SantaBarbara_1026    California_SantaBarbara_1027    California_SantaBarbara_1030    California_SantaBarbara_2002    California_SantaBarbara_2004    California_SantaBarbara_2005    California_SantaBarbara_4002    California_SantaBarbara_4003    California_SantaBarbara_4004    California_SantaBarbara_5001    California_SantaBarbara_8    California_SantaBarbara_9    California_SantaClara_2004    California_SantaCruz_3    California_Shasta_1001    California_Shasta_6    California_Solano_4    California_Sonoma_3    California_Stanislaus_1003    California_Stanislaus_1004    California_Stanislaus_5    California_Tulare_2002    California_Ventura_1003    California_Ventura_2002    California_Ventura_2003    California_Ventura_3001    California_Ventura_5    California_Ventura_6    California_Ventura_7001    Colorado_Adams_3001    Colorado_Arapahoe_1002    Colorado_Arapahoe_3    Colorado_Denver_2    Colorado_ElPaso_4    Colorado_ElPaso_6001    Colorado_ElPaso_6003    Colorado_ElPaso_6004    Colorado_ElPaso_6005    Colorado_ElPaso_6006    Colorado_ElPaso_6009    Colorado_ElPaso_6011    Colorado_ElPaso_6013    Connecticut_Fairfield_113    Connecticut_Fairfield_123    Connecticut_Hartford_1003    Connecticut_NewHaven_1123    Delaware_NewCastle_2002    Delaware_NewCastle_3001    DistrictOfColumbia_DistrictofColumbia_17    DistrictOfColumbia_DistrictofColumbia_25    Florida_Duval_32    Florida_Duval_70    Florida_Hillsborough_1052    Florida_Hillsborough_1055    Florida_Miami_Dade_27    Florida_Miami_Dade_4002    Florida_Orange_2002    Florida_PalmBeach_1004    Florida_PalmBeach_1101    Florida_Pinellas_18    Georgia_DeKalb_2    Georgia_Fulton_48    Illinois_Cook_1002    Illinois_Cook_1102    Illinois_Cook_1601    Illinois_Cook_3101    Illinois_Cook_3102    Illinois_Cook_3601    Illinois_Cook_37    Illinois_Cook_39    Illinois_Cook_40    Illinois_Cook_4002    Illinois_Cook_4003    Illinois_Cook_4004    Illinois_Cook_4005    Illinois_Cook_45    Illinois_Cook_53    Illinois_Cook_63    Illinois_DuPage_1003    Illinois_SaintClair_10    Indiana_Allen_6    Indiana_Clark_3    Indiana_Jasper_2    Indiana_Jasper_3    Indiana_Jefferson_1    Indiana_Knox_4    Indiana_Lake_1016    Indiana_Marion_30    Indiana_Marion_57    Indiana_Marion_65    Indiana_Marion_70    Indiana_Porter_15    Indiana_Porter_16    Indiana_Posey_1    Indiana_Posey_1002    Indiana_Posey_2    Indiana_Spencer_2    Indiana_Spencer_6    Indiana_Sullivan_1    Indiana_Tippecanoe_1001    Indiana_Vanderburgh_1001    Indiana_Vanderburgh_1002    Indiana_Vigo_1012    Kansas_Wyandotte_1    Kentucky_Boone_7    Kentucky_Boyd_10    Kentucky_Campbell_1001    Kentucky_Daviess_5    Kentucky_Fayette_12    Kentucky_Henderson_13    Kentucky_Jefferson_1020    Kentucky_McCracken_1024    Kentucky_Trigg_1    Louisiana_Calcasieu_100    Louisiana_EastBatonRouge_4    Louisiana_Jefferson_1001    Louisiana_Orleans_12    Louisiana_WestBatonRouge_1    Maryland_AnneArundel_19    Maryland_BaltimoreCity_40    Maryland_Baltimore_10    Maryland_Baltimore_3001    Massachusetts_Bristol_1004    Massachusetts_Essex_5    Massachusetts_Hampden_15    Massachusetts_Hampden_16    Massachusetts_Hampden_17    Massachusetts_Hampshire_4002    Massachusetts_Norfolk_8    Massachusetts_Norfolk_9    Massachusetts_Suffolk_1003    Massachusetts_Suffolk_2    Massachusetts_Suffolk_21    Massachusetts_Suffolk_35    Massachusetts_Suffolk_36    Massachusetts_Suffolk_37    Massachusetts_Worcester_20    Michigan_Dickinson_901    Michigan_Dickinson_902    Michigan_Kent_20    Michigan_Midland_940    Michigan_Midland_941    Michigan_Oakland_902    Michigan_Wayne_16    Michigan_Wayne_19    Michigan_Wayne_29    Minnesota_Carlton_6316    Minnesota_Hennepin_50    Minnesota_Hennepin_953    Minnesota_Ramsey_1    Minnesota_Ramsey_3    Minnesota_Ramsey_864    Minnesota_Wright_7    Missouri_Atchison_1    Missouri_Atchison_2    Missouri_Clay_25    Missouri_Clay_5    Missouri_Greene_14    Missouri_Greene_36    Missouri_Jackson_33    Missouri_Platte_23    Missouri_SaintCharles_1002    Missouri_SaintLouis_1    Missouri_SaintLouis_3001    Missouri_SaintLouis_5001    Missouri_SaintLouis_6    Missouri_SaintLouis_7001    Missouri_StLouisCity_72    Missouri_StLouisCity_80    Montana_Missoula_34    Montana_Rosebud_700    Montana_Rosebud_701    Montana_Rosebud_702    Montana_Rosebud_704    Montana_Rosebud_760    Montana_Rosebud_761    Montana_Rosebud_762    Nevada_Clark_1001    Nevada_Clark_16    Nevada_Clark_557    Nevada_Washoe_15    Nevada_Washoe_16    NewHampshire_Hillsborough_16    NewJersey_Bergen_1    NewJersey_Camden_3    NewJersey_Essex_1003    NewJersey_Essex_11    NewJersey_Hudson_6    NewJersey_Morris_3001    NewJersey_Union_4    NewJersey_Union_5001    NewMexico_Bernalillo_15    NewMexico_Bernalillo_23    NewMexico_Catron_1    NewMexico_Eddy_3    NewMexico_SanJuan_14    NewYork_Bronx_74    NewYork_Erie_2    NewYork_Erie_5    NewYork_Essex_5    NewYork_Nassau_5    NewYork_NewYork_10    NewYork_NewYork_56    NewYork_NewYork_63    NorthCarolina_Forsyth_22    NorthCarolina_Forsyth_7    NorthCarolina_Mecklenburg_34    NorthCarolina_Wake_14    NorthDakota_Burke_1    NorthDakota_Dunn_3    NorthDakota_Mercer_1    NorthDakota_Mercer_101    NorthDakota_Mercer_102    NorthDakota_Mercer_103    NorthDakota_Mercer_104    NorthDakota_Oliver_101    NorthDakota_Oliver_2    Ohio_Cuyahoga_2003    Ohio_Cuyahoga_33    Ohio_Cuyahoga_43    Ohio_Franklin_4    Ohio_Hamilton_1013    Ohio_Hamilton_35    Ohio_Hamilton_4002    Ohio_Jefferson_1012    Ohio_Montgomery_29    Ohio_Pickaway_1    Ohio_Pickaway_1001    Ohio_Stark_16    Oklahoma_Cleveland_44    Oklahoma_Cleveland_49    Oklahoma_Kay_600    Oklahoma_Muskogee_167    Oklahoma_Oklahoma_1037    Oklahoma_Oklahoma_33    Oklahoma_Tulsa_127    Oklahoma_Tulsa_174    Oklahoma_Tulsa_191    Oregon_Multnomah_80    Pennsylvania_Allegheny_3    Pennsylvania_Allegheny_31    Pennsylvania_Allegheny_8    Pennsylvania_Beaver_14    Pennsylvania_Berks_9    Pennsylvania_Blair_801    Pennsylvania_Bucks_12    Pennsylvania_Cambria_11    Pennsylvania_Dauphin_401    Pennsylvania_Delaware_2    Pennsylvania_Erie_10    Pennsylvania_Erie_3    Pennsylvania_Lackawanna_2006    Pennsylvania_Lancaster_7    Pennsylvania_Lawrence_15    Pennsylvania_Lehigh_4    Pennsylvania_Luzerne_1101    Pennsylvania_Montgomery_13    Pennsylvania_Northampton_17    Pennsylvania_Perry_301    Pennsylvania_Philadelphia_22    Pennsylvania_Philadelphia_23    Pennsylvania_Philadelphia_29    Pennsylvania_Philadelphia_4    Pennsylvania_Philadelphia_47    Pennsylvania_Washington_200    Pennsylvania_Washington_5    Pennsylvania_York_8    RhodeIsland_Providence_12    RhodeIsland_Providence_19    SouthCarolina_Aiken_3    SouthCarolina_Barnwell_1    SouthCarolina_Lexington_5    SouthCarolina_Richland_1006    Tennessee_Bradley_102    Tennessee_Davidson_10    Tennessee_Davidson_11    Tennessee_Giles_1    Tennessee_Maury_106    Tennessee_McMinn_101    Tennessee_Rutherford_101    Tennessee_Shelby_24    Tennessee_Sullivan_7    Tennessee_Sullivan_9    Tennessee_Williamson_103    Texas_Bexar_36    Texas_Brazoria_1003    Texas_Dallas_44    Texas_Dallas_45    Texas_Dallas_55    Texas_Dallas_69    Texas_ElPaso_27    Texas_ElPaso_37    Texas_Galveston_1002    Texas_Gregg_1    Texas_Harris_1034    Texas_Harris_1035    Texas_Harris_1037    Texas_Harris_24    Texas_Harris_26    Texas_Harris_47    Texas_Harris_7001    Texas_Jefferson_9    Texas_Orange_1001    Texas_Tarrant_1002    Texas_Tarrant_1003    Texas_Travis_17    Utah_Davis_1    Utah_SaltLake_3001    Utah_Utah_2    Utah_Weber_1    Vermont_Chittenden_3    Vermont_Rutland_2    Virginia_AlexandriaCity_9    Virginia_Arlington_20    Virginia_FairfaxCity_5    Virginia_Fairfax_1004    Virginia_Fairfax_18    Virginia_Fairfax_5001    Virginia_Henrico_14    Virginia_NorfolkCity_23    Virginia_RichmondCity_21    Virginia_Roanoke_1004    Virginia_VirginiaBeachCity_7    Washington_King_80    Washington_King_82    WestVirginia_Cabell_6    WestVirginia_Greenbrier_1    WestVirginia_Hancock_1004    WestVirginia_Kanawha_4    WestVirginia_Ohio_7    Wisconsin_Columbia_8    Wisconsin_Kenosha_1001    Wisconsin_Kenosha_16    Wisconsin_Milwaukee_41    Wisconsin_Milwaukee_80    Wisconsin_Rock_1002    Wisconsin_Rock_1004
    ____    __________________________    _________________    _________________    ________________    ________________    ________________    _____________________    _____________________    _________________    _______________    ______________    _____________________    _______________________    ____________________    __________________    ___________________________    ________________________    ________________________    ___________________________    _____________________    _____________________    _____________________    ___________________    ___________________    ___________________    ___________________    _________________    ____________________    _________________    ____________________    _________________    __________________________    __________________________    __________________________    _________________________    __________________________    __________________________    ________________________    __________________________    __________________________    _______________________    __________________________    __________________________    __________________________    __________________________    __________________________    __________________________    __________________________    __________________________    __________________    ______________________    ________________________    _________________    ___________________    ______________________    ______________________    ______________________    _________________________    _________________________    _________________________    _______________________    ________________________    __________________________    _______________________    __________________________    _______________________    __________________________    _____________________________    ___________________________    _____________________________    __________________________    _____________________________    __________________________    _____________________________    _____________________________    _____________________    ________________________    ________________________    ________________________    ________________________    _____________________    _____________________    _____________________    _________________________    _________________________    __________________________    _____________________________    _____________________________    _____________________________    _____________________________    ________________________    __________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    _________________________    _________________________    __________________________    ______________________    ______________________    ___________________    ___________________    ___________________    __________________________    __________________________    _______________________    ______________________    _______________________    _______________________    _______________________    _______________________    ____________________    ____________________    _______________________    ___________________    ______________________    ___________________    _________________    _________________    ____________________    ____________________    ____________________    ____________________    ____________________    ____________________    ____________________    ____________________    _________________________    _________________________    _________________________    _________________________    _______________________    _______________________    ________________________________________    ________________________________________    ________________    ________________    _________________________    _________________________    _____________________    _______________________    ___________________    ______________________    ______________________    ___________________    ________________    _________________    __________________    __________________    __________________    __________________    __________________    __________________    ________________    ________________    ________________    __________________    __________________    __________________    __________________    ________________    ________________    ________________    ____________________    ______________________    _______________    _______________    ________________    ________________    ___________________    ______________    _________________    _________________    _________________    _________________    _________________    _________________    _________________    _______________    __________________    _______________    _________________    _________________    __________________    _______________________    ________________________    ________________________    _________________    __________________    ________________    ________________    ______________________    __________________    ___________________    _____________________    _______________________    _______________________    ________________    _______________________    __________________________    ________________________    ____________________    __________________________    _______________________    _________________________    _____________________    _______________________    __________________________    _____________________    ________________________    ________________________    ________________________    ____________________________    _______________________    _______________________    __________________________    _______________________    ________________________    ________________________    ________________________    ________________________    __________________________    ______________________    ______________________    ________________    ____________________    ____________________    ____________________    _________________    _________________    _________________    ______________________    _____________________    ______________________    __________________    __________________    ____________________    __________________    ___________________    ___________________    ________________    _______________    __________________    __________________    ___________________    __________________    __________________________    _____________________    ________________________    ________________________    _____________________    ________________________    _______________________    _______________________    ___________________    ___________________    ___________________    ___________________    ___________________    ___________________    ___________________    ___________________    _________________    _______________    ________________    ________________    ________________    ____________________________    __________________    __________________    ____________________    __________________    __________________    _____________________    _________________    ____________________    _______________________    _______________________    __________________    ________________    ____________________    ________________    ______________    ______________    _______________    ________________    __________________    __________________    __________________    ________________________    _______________________    ____________________________    _____________________    ___________________    __________________    ____________________    ______________________    ______________________    ______________________    ______________________    ______________________    ____________________    __________________    ________________    ________________    _______________    __________________    ________________    __________________    ___________________    __________________    _______________    __________________    _____________    _____________________    _____________________    ________________    _____________________    ______________________    ____________________    __________________    __________________    __________________    ___________________    ________________________    _________________________    ________________________    ______________________    ____________________    ______________________    _____________________    _______________________    ________________________    _______________________    ____________________    ___________________    ____________________________    ________________________    ________________________    _____________________    _________________________    __________________________    ___________________________    ______________________    ____________________________    ____________________________    ____________________________    ___________________________    ____________________________    ___________________________    _________________________    ___________________    _________________________    _________________________    _____________________    ________________________    _________________________    ___________________________    _____________________    _____________________    _____________________    _________________    ___________________    ____________________    ________________________    ___________________    ____________________    ____________________    ________________________    ______________    ___________________    _______________    _______________    _______________    _______________    _______________    _______________    ____________________    _____________    _________________    _________________    _________________    _______________    _______________    _______________    _________________    _________________    _________________    __________________    __________________    _______________    ____________    __________________    ___________    ____________    ____________________    _________________    _________________________    _____________________    ______________________    _____________________    ___________________    _____________________    ___________________    _______________________    ________________________    _____________________    ____________________________    __________________    __________________    _____________________    _________________________    _________________________    ______________________    ___________________    ____________________    ______________________    ____________________    ______________________    ______________________    ___________________    ___________________

    1989              9.7986                   6.9929               7.5714               6.9146              7.2619              6.9604                   NaN                      NaN                 19.756              25.689             27.227               12.066                    26.196                    22.652                 16.322                    17.069                        23.601                      23.539                       20.121                      14.488                   17.632                   20.123                  32.092                    NaN                  25.63                 21.521                33.682                 13.708                   NaN                 22.502                17.431                    51.026                        55.335                           NaN                       33.294                        39.365                        46.157                       39.372                       54.685                        57.118                      51.135                       53.174                        44.575                         42.93                        29.629                        39.111                        37.877                        19.853                          NaN                     22.555                    NaN                      14.988                  18.075                47.195                    37.19                     43.02                       NaN                     24.132                       32.392                       37.062                      20.855                      25.009                       18.622                      17.045                       17.725                      25.017                       26.622                         44.851                          13.684                          37.511                             NaN                         19.918                          16.094                            NaN                           41.653                       27.655                     32.466                      37.276                      18.508                      35.96                     30.693                   27.044                   27.493                        NaN                       26.059                        25.598                         11.694                           16.023                           17.585                           13.495                         24.317                       27.267                         12.192                          6.8022                          7.4621                          6.0716                           6.024                          9.3787                           9.406                          11.892                          9.7051                          9.7773                          18.279                          9.1268                          9.2821                          8.3069                          9.3139                          7.2573                           18.54                          14.527                             NaN                             NaN                           6.433                          6.6575                             NaN                        16.863                          NaN                        34.421                      11.895                      NaN                   16.747                 20.459                 17.455                        NaN                        14.707                      26.935                     23.164                    14.554                      27.47                     18.231                     19.073                    11.033                  13.273                      NaN                   29.366                      NaN                  22.103                40.313                  NaN                 12.714                  16.409                  19.683                  23.401                  11.403                  16.267                  23.618                  25.598                    25.759                          NaN                       20.889                       28.421                      33.532                     28.746                              25.898                                      19.397                          16.372                 NaN                  22.114                          NaN                     14.271                     18.42                   13.979                   14.196                       NaN                  16.546                19.791              28.933                  23.9                   NaN                17.284                 31.36                29.417                29.535               26.866              34.424                 NaN               27.441                 23.05                29.568                24.884                  NaN                 NaN              32.554                25.617                   22.677                13.897                NaN                 NaN                 NaN                  NaN                  NaN             34.163                  NaN               21.582               25.471               23.033                  NaN                  NaN                 NaN                  NaN              13.036              9.8545               9.4845                   NaN                     NaN                         NaN                         NaN                     NaN                32.844                  NaN              16.385                 20.575                  14.368                19.911                  23.832                    26.838                      15.57                     NaN                    NaN                       20.097                       15.164                    22.077                     17.042                       18.46                      35.227                        NaN                    25.526                          NaN                        NaN                        NaN                      28.953                         NaN                         12.54                       21.528                     26.423                       29.594                       32.31                       32.13                       24.06                       26.43                      23.926                       26.179                      11.332                    8.6171                 18.412                12.076                  11.082                     NaN                25.104                  NaN               25.591                  8.1999                   22.078                    25.228                     NaN                   NaN                 20.237                 11.668                   NaN                    NaN                17.968             12.712                  NaN                16.544                   NaN                 13.007                    16.678                     22.031                      20.57                      21.325                    17.047                      23.86                     26.534                     20.372                   14.493                 11.466                 10.188                   8.66                  9.169                 9.8034                 8.0625                 10.547                   NaN               35.57              30.477                 NaN                 NaN                    22.833                     34.686                25.264                 32.765                 33.182                 31.38                 16.314                 37.654                 23.908                      NaN                     19.504                      NaN               12.437                14.919                   NaN             19.656            24.038            7.9884              29.446               41.977                49.448                   NaN                   15.668                     13.546                        19.253                      13.737                  6.5652                 6.7879                 8.9777                      NaN                    7.9715                    7.7364                    10.251                       NaN                   8.9198                    NaN               33.657              24.804                NaN                  NaN               29.817               27.515                 23.01                    NaN                 NaN                12.49                NaN                  NaN                   14.216                 13.302                10.997                    13.619                   16.072                    NaN                13.431                20.415                15.932                    25.838                      28.295                        25.79                     20.556                   23.377                     NaN                    24.989                    19.175                      22.115                        NaN                       NaN                 16.646                      22.342                        18.152                       19.69                    21.258                     19.031                           NaN                           NaN                       10.934                          NaN                             NaN                          32.935                         29.186                          39.744                         20.817                        20.624                      22.6                    23.634                          NaN                     10.253                     7.9022                         NaN                        10.265                      13.636                      NaN                   14.546                    NaN                10.882                  13.834                    6.6817                   26.657                  19.766                     NaN                    7.2863                    NaN                 NaN                  NaN             17.914             13.754             21.998                NaN             22.736                  NaN                  NaN             21.837                23.29               27.548              17.805                NaN             23.565                 NaN               13.025               14.187                18.882                   NaN              18.128            21.987             32.907            29.279           28.75              19.088                15.678                   31.226                     26.319                    23.639                   27.847                  22.203                  29.668                  16.617                   20.578                      24.855                    15.169                       20.507                        NaN                   NaN                 16.234                     8.3624                        20.15                       22.11                  19.306                  10.498                      NaN                   17.218                   20.235                    28.515                     NaN                    NaN       
    1985                 NaN                   8.4406               8.4264                 7.75              5.9138              6.7021                24.546                   15.514                 18.531                 NaN             24.518               11.748                    26.308                    22.396                  15.87                    15.428                        23.182                      21.806                       17.941                      15.142                      NaN                      NaN                  31.365                  19.75                 20.952                 26.921                30.993                    NaN                   NaN                    NaN                   NaN                    57.401                        59.965                        58.399                       38.492                        39.672                        52.548                          NaN                       53.377                        54.147                      50.289                       50.162                        47.958                        50.114                           NaN                           NaN                           NaN                        17.384                        43.92                     24.229                    NaN                      15.855                  18.447                43.104                   29.302                    42.811                       NaN                     20.183                          NaN                       35.461                      22.077                         NaN                       18.823                      18.546                          NaN                      20.747                       26.424                         39.996                             NaN                          37.844                          38.204                            NaN                          13.073                         21.232                              NaN                       27.568                     27.879                      32.718                      17.111                        NaN                     31.908                      NaN                   25.372                     28.254                          NaN                        20.258                         11.732                           15.251                           17.762                           13.598                          22.81                          NaN                            NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                          18.188                             NaN                          11.797                             NaN                             NaN                             NaN                             NaN                        15.398                        29.84                           NaN                         NaN                    11.09                      NaN                 20.359                 17.994                        NaN                           NaN                      22.091                       22.5                       NaN                        NaN                     20.857                     19.645                    11.459                     NaN                   27.996                   28.659                   19.921                     NaN                47.934               23.989                    NaN                     NaN                     NaN                     NaN                     NaN                     NaN                     NaN                     NaN                       NaN                       27.085                       21.763                        30.71                      29.012                      25.01                               36.44                                      28.321                           16.73              11.309                  19.458                       16.542                       11.3                    17.428                   11.708                      NaN                    14.395                  17.472                15.937              27.001                22.592                24.021                17.317                34.109                   NaN                   NaN               27.304                34.9              42.464               27.823                   NaN                   NaN                   NaN               24.622              24.338                 NaN                   NaN                   22.475                   NaN             16.508              12.728              11.049               11.159                  NaN                NaN               21.894               20.817                  NaN               18.893               13.242               13.404                 NaN               24.704                 NaN              10.191               10.965                10.863                     NaN                       12.02                      14.059                  12.323                   NaN               13.912              17.453                 21.639                  13.276                18.625                  25.127                    23.747                     16.189                  7.3081                 12.353                       24.902                       16.618                    24.532                     22.192                      20.122                      35.846                      18.22                    26.679                       18.263                     22.122                     25.231                         NaN                         NaN                           NaN                          NaN                        NaN                       24.399                      39.768                      30.652                         NaN                         NaN                      25.344                          NaN                      11.918                    9.3198                    NaN                   NaN                     NaN                  16.595                8.6867                22.76                  NaN                     NaN                   18.871                       NaN                     NaN                21.701                    NaN                    NaN                   NaN                    NaN                16.102             10.219               8.6515                   NaN                25.521                  15.02                    13.793                     22.332                      20.21                      19.638                    15.016                        NaN                     34.309                     23.916                      NaN                 12.593                 12.093                 8.9425                 10.568                 9.4729                 8.9321                 9.3806                 33.51                 NaN              27.971                 NaN              27.348                       NaN                     33.968                27.979                 30.159                 33.573                 32.32                 15.408                 42.927                 23.856                   19.197                        NaN                   7.2632                  NaN                17.908                32.466             19.512             24.49            6.1648              33.617               42.346                   NaN                   NaN                   15.117                        NaN                        19.708                         NaN                     NaN                 6.1797                 9.0852                   7.6016                    8.3062                    7.0871                    9.0084                    7.6155                      NaN                    NaN               29.908              22.072             25.342               18.026               29.099               29.067                19.529                 22.141                 NaN                  NaN             19.598                19.67                      NaN                    NaN                   NaN                    13.974                    17.06                 16.525                12.774                20.443                 19.25                       NaN                      29.692                       27.063                     23.138                   23.368                   18.04                    25.828                    20.217                      22.045                     24.373                    17.031                    NaN                       23.05                        19.274                      21.778                    19.444                     21.536                        23.813                        21.589                       10.948                       31.667                             NaN                          34.406                         33.719                          36.223                         19.809                        18.619                    25.262                    26.242                          NaN                        NaN                      8.916                         NaN                        7.8505                      13.259                      NaN                      NaN                  13.02                   NaN                  12.057                       NaN                   18.537                   19.75                  17.573                       NaN                 16.809              15.465               22.288             18.562             15.853                NaN             24.654             19.713                14.71               11.741             21.096               25.421               28.928              17.341             15.587             23.676              14.588               14.603               11.179                20.275                 23.15                 NaN               NaN             38.119            31.138          31.073              16.922                   NaN                   29.671                     24.991                    23.347                   25.148                   21.04                  25.784                     NaN                      NaN                       23.05                    14.758                       18.108                     19.799                34.428                 16.663                     8.6705                       18.629                       23.72                  17.997                  11.788                   14.625                   14.075                   18.757                    26.559                  14.536                 13.956       

This representation of the annual means by site has an advantage and a disadvantage.

  • It is easier to look at the short five-year time series for each site. After unstacking, each site has its own variable in pivotedMeanNO2bySiteID. You can easily compare sites to each other.

  • It is harder to sort and pick out the largest values across the whole pivoted table. After unstacking, pivotedMeanNO2bySiteID has 443 variables. The stacked version, meanNO2bySite, has only seven variables.

Group by Time and Another Grouping Variable

To group data in NO2data by year and another grouping variable, it was necessary to add Year as an additional variable. Also, the output from groupsummary is a table even when the input is a timetable. But suppose you want to keep the results in a timetable instead. The retime function can also produce annual summaries. But it can group data only by time. To group data by site and by year, rearrange NO2data so that you can call retime on a timetable where the NO2 concentrations are already grouped by site.

Group the raw data in NO2data by site by using the unstack function. The output timetable has a separate variable for each site. This timetable looks similar to a pivot table. But instead of having means or some other statistic, NO2bySite has all the raw data. It is just reorganized. For further convenience, sort the rows of the timetable by their row times so that the earliest timestamps come first.

NO2bySite = unstack(NO2data,"MeasuredNO2","SiteID","GroupingVariable","Timestamp");
NO2bySite = sortrows(NO2bySite)
NO2bySite=43824×442 timetable
         Timestamp          Alaska_KenaiPeninsula_1004    Arizona_Apache_10    Arizona_Apache_11    Arizona_Apache_7    Arizona_Apache_8    Arizona_Apache_9    Arizona_Maricopa_3002    Arizona_Maricopa_3003    Arizona_Pima_1011    Arizona_Pima_19    Arizona_Pima_2    Arkansas_Pulaski_1002    California_Alameda_1001    California_Alameda_3    California_Butte_2    California_ContraCosta_1002    California_ContraCosta_2    California_ContraCosta_3    California_ContraCosta_3001    California_ElDorado_9    California_Fresno_241    California_Fresno_242    California_Fresno_5    California_Fresno_6    California_Fresno_7    California_Kern_232    California_Kern_4    California_Kern_5001    California_Kern_6    California_Kern_6001    California_Kern_7    California_LosAngeles_1002    California_LosAngeles_1103    California_LosAngeles_1105    California_LosAngeles_113    California_LosAngeles_1201    California_LosAngeles_1301    California_LosAngeles_16    California_LosAngeles_1601    California_LosAngeles_1701    California_LosAngeles_2    California_LosAngeles_2005    California_LosAngeles_2401    California_LosAngeles_4002    California_LosAngeles_4101    California_LosAngeles_5001    California_LosAngeles_6002    California_LosAngeles_7001    California_LosAngeles_8001    California_Marin_1    California_Mendocino_7    California_Monterey_1002    California_Napa_3    California_Orange_1    California_Orange_1002    California_Orange_5001    California_Plumas_1001    California_Riverside_5001    California_Riverside_6001    California_Riverside_8001    California_Sacramento_1    California_Sacramento_10    California_Sacramento_1001    California_Sacramento_2    California_Sacramento_5002    California_Sacramento_6    California_SanBernardino_1    California_SanBernardino_1004    California_SanBernardino_12    California_SanBernardino_2002    California_SanBernardino_3    California_SanBernardino_4001    California_SanBernardino_6    California_SanBernardino_7002    California_SanBernardino_9004    California_SanDiego_1    California_SanDiego_1002    California_SanDiego_1004    California_SanDiego_1006    California_SanDiego_1007    California_SanDiego_3    California_SanDiego_5    California_SanDiego_6    California_SanFrancisco_4    California_SanFrancisco_5    California_SanJoaquin_1002    California_SanLuisObispo_1004    California_SanLuisObispo_2001    California_SanLuisObispo_2002    California_SanLuisObispo_4001    California_SanMateo_1001    California_SantaBarbara_10    California_SantaBarbara_1010    California_SantaBarbara_1011    California_SantaBarbara_1012    California_SantaBarbara_1013    California_SantaBarbara_1014    California_SantaBarbara_1015    California_SantaBarbara_1016    California_SantaBarbara_1017    California_SantaBarbara_1018    California_SantaBarbara_1019    California_SantaBarbara_1020    California_SantaBarbara_1021    California_SantaBarbara_1025    California_SantaBarbara_1026    California_SantaBarbara_1027    California_SantaBarbara_1030    California_SantaBarbara_2002    California_SantaBarbara_2004    California_SantaBarbara_2005    California_SantaBarbara_4002    California_SantaBarbara_4003    California_SantaBarbara_4004    California_SantaBarbara_5001    California_SantaBarbara_8    California_SantaBarbara_9    California_SantaClara_2004    California_SantaCruz_3    California_Shasta_1001    California_Shasta_6    California_Solano_4    California_Sonoma_3    California_Stanislaus_1003    California_Stanislaus_1004    California_Stanislaus_5    California_Tulare_2002    California_Ventura_1003    California_Ventura_2002    California_Ventura_2003    California_Ventura_3001    California_Ventura_5    California_Ventura_6    California_Ventura_7001    Colorado_Adams_3001    Colorado_Arapahoe_1002    Colorado_Arapahoe_3    Colorado_Denver_2    Colorado_ElPaso_4    Colorado_ElPaso_6001    Colorado_ElPaso_6003    Colorado_ElPaso_6004    Colorado_ElPaso_6005    Colorado_ElPaso_6006    Colorado_ElPaso_6009    Colorado_ElPaso_6011    Colorado_ElPaso_6013    Connecticut_Fairfield_113    Connecticut_Fairfield_123    Connecticut_Hartford_1003    Connecticut_NewHaven_1123    Delaware_NewCastle_2002    Delaware_NewCastle_3001    DistrictOfColumbia_DistrictofColumbia_17    DistrictOfColumbia_DistrictofColumbia_25    Florida_Duval_32    Florida_Duval_70    Florida_Hillsborough_1052    Florida_Hillsborough_1055    Florida_Miami_Dade_27    Florida_Miami_Dade_4002    Florida_Orange_2002    Florida_PalmBeach_1004    Florida_PalmBeach_1101    Florida_Pinellas_18    Georgia_DeKalb_2    Georgia_Fulton_48    Illinois_Cook_1002    Illinois_Cook_1102    Illinois_Cook_1601    Illinois_Cook_3101    Illinois_Cook_3102    Illinois_Cook_3601    Illinois_Cook_37    Illinois_Cook_39    Illinois_Cook_40    Illinois_Cook_4002    Illinois_Cook_4003    Illinois_Cook_4004    Illinois_Cook_4005    Illinois_Cook_45    Illinois_Cook_53    Illinois_Cook_63    Illinois_DuPage_1003    Illinois_SaintClair_10    Indiana_Allen_6    Indiana_Clark_3    Indiana_Jasper_2    Indiana_Jasper_3    Indiana_Jefferson_1    Indiana_Knox_4    Indiana_Lake_1016    Indiana_Marion_30    Indiana_Marion_57    Indiana_Marion_65    Indiana_Marion_70    Indiana_Porter_15    Indiana_Porter_16    Indiana_Posey_1    Indiana_Posey_1002    Indiana_Posey_2    Indiana_Spencer_2    Indiana_Spencer_6    Indiana_Sullivan_1    Indiana_Tippecanoe_1001    Indiana_Vanderburgh_1001    Indiana_Vanderburgh_1002    Indiana_Vigo_1012    Kansas_Wyandotte_1    Kentucky_Boone_7    Kentucky_Boyd_10    Kentucky_Campbell_1001    Kentucky_Daviess_5    Kentucky_Fayette_12    Kentucky_Henderson_13    Kentucky_Jefferson_1020    Kentucky_McCracken_1024    Kentucky_Trigg_1    Louisiana_Calcasieu_100    Louisiana_EastBatonRouge_4    Louisiana_Jefferson_1001    Louisiana_Orleans_12    Louisiana_WestBatonRouge_1    Maryland_AnneArundel_19    Maryland_BaltimoreCity_40    Maryland_Baltimore_10    Maryland_Baltimore_3001    Massachusetts_Bristol_1004    Massachusetts_Essex_5    Massachusetts_Hampden_15    Massachusetts_Hampden_16    Massachusetts_Hampden_17    Massachusetts_Hampshire_4002    Massachusetts_Norfolk_8    Massachusetts_Norfolk_9    Massachusetts_Suffolk_1003    Massachusetts_Suffolk_2    Massachusetts_Suffolk_21    Massachusetts_Suffolk_35    Massachusetts_Suffolk_36    Massachusetts_Suffolk_37    Massachusetts_Worcester_20    Michigan_Dickinson_901    Michigan_Dickinson_902    Michigan_Kent_20    Michigan_Midland_940    Michigan_Midland_941    Michigan_Oakland_902    Michigan_Wayne_16    Michigan_Wayne_19    Michigan_Wayne_29    Minnesota_Carlton_6316    Minnesota_Hennepin_50    Minnesota_Hennepin_953    Minnesota_Ramsey_1    Minnesota_Ramsey_3    Minnesota_Ramsey_864    Minnesota_Wright_7    Missouri_Atchison_1    Missouri_Atchison_2    Missouri_Clay_25    Missouri_Clay_5    Missouri_Greene_14    Missouri_Greene_36    Missouri_Jackson_33    Missouri_Platte_23    Missouri_SaintCharles_1002    Missouri_SaintLouis_1    Missouri_SaintLouis_3001    Missouri_SaintLouis_5001    Missouri_SaintLouis_6    Missouri_SaintLouis_7001    Missouri_StLouisCity_72    Missouri_StLouisCity_80    Montana_Missoula_34    Montana_Rosebud_700    Montana_Rosebud_701    Montana_Rosebud_702    Montana_Rosebud_704    Montana_Rosebud_760    Montana_Rosebud_761    Montana_Rosebud_762    Nevada_Clark_1001    Nevada_Clark_16    Nevada_Clark_557    Nevada_Washoe_15    Nevada_Washoe_16    NewHampshire_Hillsborough_16    NewJersey_Bergen_1    NewJersey_Camden_3    NewJersey_Essex_1003    NewJersey_Essex_11    NewJersey_Hudson_6    NewJersey_Morris_3001    NewJersey_Union_4    NewJersey_Union_5001    NewMexico_Bernalillo_15    NewMexico_Bernalillo_23    NewMexico_Catron_1    NewMexico_Eddy_3    NewMexico_SanJuan_14    NewYork_Bronx_74    NewYork_Erie_2    NewYork_Erie_5    NewYork_Essex_5    NewYork_Nassau_5    NewYork_NewYork_10    NewYork_NewYork_56    NewYork_NewYork_63    NorthCarolina_Forsyth_22    NorthCarolina_Forsyth_7    NorthCarolina_Mecklenburg_34    NorthCarolina_Wake_14    NorthDakota_Burke_1    NorthDakota_Dunn_3    NorthDakota_Mercer_1    NorthDakota_Mercer_101    NorthDakota_Mercer_102    NorthDakota_Mercer_103    NorthDakota_Mercer_104    NorthDakota_Oliver_101    NorthDakota_Oliver_2    Ohio_Cuyahoga_2003    Ohio_Cuyahoga_33    Ohio_Cuyahoga_43    Ohio_Franklin_4    Ohio_Hamilton_1013    Ohio_Hamilton_35    Ohio_Hamilton_4002    Ohio_Jefferson_1012    Ohio_Montgomery_29    Ohio_Pickaway_1    Ohio_Pickaway_1001    Ohio_Stark_16    Oklahoma_Cleveland_44    Oklahoma_Cleveland_49    Oklahoma_Kay_600    Oklahoma_Muskogee_167    Oklahoma_Oklahoma_1037    Oklahoma_Oklahoma_33    Oklahoma_Tulsa_127    Oklahoma_Tulsa_174    Oklahoma_Tulsa_191    Oregon_Multnomah_80    Pennsylvania_Allegheny_3    Pennsylvania_Allegheny_31    Pennsylvania_Allegheny_8    Pennsylvania_Beaver_14    Pennsylvania_Berks_9    Pennsylvania_Blair_801    Pennsylvania_Bucks_12    Pennsylvania_Cambria_11    Pennsylvania_Dauphin_401    Pennsylvania_Delaware_2    Pennsylvania_Erie_10    Pennsylvania_Erie_3    Pennsylvania_Lackawanna_2006    Pennsylvania_Lancaster_7    Pennsylvania_Lawrence_15    Pennsylvania_Lehigh_4    Pennsylvania_Luzerne_1101    Pennsylvania_Montgomery_13    Pennsylvania_Northampton_17    Pennsylvania_Perry_301    Pennsylvania_Philadelphia_22    Pennsylvania_Philadelphia_23    Pennsylvania_Philadelphia_29    Pennsylvania_Philadelphia_4    Pennsylvania_Philadelphia_47    Pennsylvania_Washington_200    Pennsylvania_Washington_5    Pennsylvania_York_8    RhodeIsland_Providence_12    RhodeIsland_Providence_19    SouthCarolina_Aiken_3    SouthCarolina_Barnwell_1    SouthCarolina_Lexington_5    SouthCarolina_Richland_1006    Tennessee_Bradley_102    Tennessee_Davidson_10    Tennessee_Davidson_11    Tennessee_Giles_1    Tennessee_Maury_106    Tennessee_McMinn_101    Tennessee_Rutherford_101    Tennessee_Shelby_24    Tennessee_Sullivan_7    Tennessee_Sullivan_9    Tennessee_Williamson_103    Texas_Bexar_36    Texas_Brazoria_1003    Texas_Dallas_44    Texas_Dallas_45    Texas_Dallas_55    Texas_Dallas_69    Texas_ElPaso_27    Texas_ElPaso_37    Texas_Galveston_1002    Texas_Gregg_1    Texas_Harris_1034    Texas_Harris_1035    Texas_Harris_1037    Texas_Harris_24    Texas_Harris_26    Texas_Harris_47    Texas_Harris_7001    Texas_Jefferson_9    Texas_Orange_1001    Texas_Tarrant_1002    Texas_Tarrant_1003    Texas_Travis_17    Utah_Davis_1    Utah_SaltLake_3001    Utah_Utah_2    Utah_Weber_1    Vermont_Chittenden_3    Vermont_Rutland_2    Virginia_AlexandriaCity_9    Virginia_Arlington_20    Virginia_FairfaxCity_5    Virginia_Fairfax_1004    Virginia_Fairfax_18    Virginia_Fairfax_5001    Virginia_Henrico_14    Virginia_NorfolkCity_23    Virginia_RichmondCity_21    Virginia_Roanoke_1004    Virginia_VirginiaBeachCity_7    Washington_King_80    Washington_King_82    WestVirginia_Cabell_6    WestVirginia_Greenbrier_1    WestVirginia_Hancock_1004    WestVirginia_Kanawha_4    WestVirginia_Ohio_7    Wisconsin_Columbia_8    Wisconsin_Kenosha_1001    Wisconsin_Kenosha_16    Wisconsin_Milwaukee_41    Wisconsin_Milwaukee_80    Wisconsin_Rock_1002    Wisconsin_Rock_1004
    ____________________    __________________________    _________________    _________________    ________________    ________________    ________________    _____________________    _____________________    _________________    _______________    ______________    _____________________    _______________________    ____________________    __________________    ___________________________    ________________________    ________________________    ___________________________    _____________________    _____________________    _____________________    ___________________    ___________________    ___________________    ___________________    _________________    ____________________    _________________    ____________________    _________________    __________________________    __________________________    __________________________    _________________________    __________________________    __________________________    ________________________    __________________________    __________________________    _______________________    __________________________    __________________________    __________________________    __________________________    __________________________    __________________________    __________________________    __________________________    __________________    ______________________    ________________________    _________________    ___________________    ______________________    ______________________    ______________________    _________________________    _________________________    _________________________    _______________________    ________________________    __________________________    _______________________    __________________________    _______________________    __________________________    _____________________________    ___________________________    _____________________________    __________________________    _____________________________    __________________________    _____________________________    _____________________________    _____________________    ________________________    ________________________    ________________________    ________________________    _____________________    _____________________    _____________________    _________________________    _________________________    __________________________    _____________________________    _____________________________    _____________________________    _____________________________    ________________________    __________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    _________________________    _________________________    __________________________    ______________________    ______________________    ___________________    ___________________    ___________________    __________________________    __________________________    _______________________    ______________________    _______________________    _______________________    _______________________    _______________________    ____________________    ____________________    _______________________    ___________________    ______________________    ___________________    _________________    _________________    ____________________    ____________________    ____________________    ____________________    ____________________    ____________________    ____________________    ____________________    _________________________    _________________________    _________________________    _________________________    _______________________    _______________________    ________________________________________    ________________________________________    ________________    ________________    _________________________    _________________________    _____________________    _______________________    ___________________    ______________________    ______________________    ___________________    ________________    _________________    __________________    __________________    __________________    __________________    __________________    __________________    ________________    ________________    ________________    __________________    __________________    __________________    __________________    ________________    ________________    ________________    ____________________    ______________________    _______________    _______________    ________________    ________________    ___________________    ______________    _________________    _________________    _________________    _________________    _________________    _________________    _________________    _______________    __________________    _______________    _________________    _________________    __________________    _______________________    ________________________    ________________________    _________________    __________________    ________________    ________________    ______________________    __________________    ___________________    _____________________    _______________________    _______________________    ________________    _______________________    __________________________    ________________________    ____________________    __________________________    _______________________    _________________________    _____________________    _______________________    __________________________    _____________________    ________________________    ________________________    ________________________    ____________________________    _______________________    _______________________    __________________________    _______________________    ________________________    ________________________    ________________________    ________________________    __________________________    ______________________    ______________________    ________________    ____________________    ____________________    ____________________    _________________    _________________    _________________    ______________________    _____________________    ______________________    __________________    __________________    ____________________    __________________    ___________________    ___________________    ________________    _______________    __________________    __________________    ___________________    __________________    __________________________    _____________________    ________________________    ________________________    _____________________    ________________________    _______________________    _______________________    ___________________    ___________________    ___________________    ___________________    ___________________    ___________________    ___________________    ___________________    _________________    _______________    ________________    ________________    ________________    ____________________________    __________________    __________________    ____________________    __________________    __________________    _____________________    _________________    ____________________    _______________________    _______________________    __________________    ________________    ____________________    ________________    ______________    ______________    _______________    ________________    __________________    __________________    __________________    ________________________    _______________________    ____________________________    _____________________    ___________________    __________________    ____________________    ______________________    ______________________    ______________________    ______________________    ______________________    ____________________    __________________    ________________    ________________    _______________    __________________    ________________    __________________    ___________________    __________________    _______________    __________________    _____________    _____________________    _____________________    ________________    _____________________    ______________________    ____________________    __________________    __________________    __________________    ___________________    ________________________    _________________________    ________________________    ______________________    ____________________    ______________________    _____________________    _______________________    ________________________    _______________________    ____________________    ___________________    ____________________________    ________________________    ________________________    _____________________    _________________________    __________________________    ___________________________    ______________________    ____________________________    ____________________________    ____________________________    ___________________________    ____________________________    ___________________________    _________________________    ___________________    _________________________    _________________________    _____________________    ________________________    _________________________    ___________________________    _____________________    _____________________    _____________________    _________________    ___________________    ____________________    ________________________    ___________________    ____________________    ____________________    ________________________    ______________    ___________________    _______________    _______________    _______________    _______________    _______________    _______________    ____________________    _____________    _________________    _________________    _________________    _______________    _______________    _______________    _________________    _________________    _________________    __________________    __________________    _______________    ____________    __________________    ___________    ____________    ____________________    _________________    _________________________    _____________________    ______________________    _____________________    ___________________    _____________________    ___________________    _______________________    ________________________    _____________________    ____________________________    __________________    __________________    _____________________    _________________________    _________________________    ______________________    ___________________    ____________________    ______________________    ____________________    ______________________    ______________________    ___________________    ___________________

    01-Jan-1985 00:00:00               NaN                       NaN                  NaN                 NaN                 NaN                 NaN                    30                       NaN                    40                  NaN               NaN                   NaN                       20                        20                     10                         30                           30                          20                           60                           20                      NaN                      NaN                      50                    NaN                    NaN                     10                    30                   NaN                    NaN                   NaN                    NaN                      120                           130                           110                           90                            10                           120                          NaN                           90                            60                          50                          110                            90                           110                           NaN                           NaN                           NaN                            30                            80                        30                     NaN                         20                      20                    10                       10                        60                       NaN                          10                          NaN                           10                          20                        NaN                           10                           20                         NaN                          20                          NaN                             NaN                             NaN                              10                            NaN                             NaN                             10                              20                              NaN                          40                         20                          70                          10                         NaN                        40                       NaN                       40                        40                           NaN                          NaN                              20                               10                               10                              10                             20                          NaN                            NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                              10                             NaN                             NaN                             NaN                             NaN                            NaN                          NaN                          NaN                         NaN                       NaN                      NaN                    20                     20                        NaN                           NaN                          NaN                        10                        NaN                        NaN                        NaN                        NaN                      NaN                     NaN                       NaN                       7                        5                      NaN                   15                   NaN                   NaN                     NaN                     NaN                     NaN                     NaN                     NaN                     NaN                     NaN                        NaN                          28                           32                           32                          50                          30                                 36                                          40                              10                 NaN                      18                             9                        NaN                       NaN                        7                     NaN                        10                      10                   NaN                 17.5                  NaN                   NaN                   NaN                   NaN                   NaN                   NaN                  NaN                  10                   8                  NaN                   NaN                   NaN                   NaN                  NaN                 NaN                 NaN                   NaN                       16                    NaN                  7                 19                  23                     9                 NaN                 NaN                  NaN                  NaN                  NaN                  NaN                   13                  NaN                 NaN                 NaN                  NaN                 NaN                  NaN                    6                      NaN                        NaN                         NaN                      11                   NaN                   17                  20                     13                     NaN                    NaN                     NaN                       NaN                        NaN                    NaN                     NaN                           5                           15                        10                         26                          36                          NaN                        NaN                       35                            7                          18                        19                         NaN                         NaN                           NaN                           NaN                        NaN                          31                           49                         44                         NaN                         NaN                         NaN                          NaN                         NaN                       NaN                    NaN                   NaN                     NaN                     NaN                    NaN                    9                  NaN                    NaN                         8                      NaN                     NaN                   NaN                    NaN                    NaN                    NaN                    NaN                  NaN                 NaN                 NaN                   NaN                    NaN                   6.3                       NaN                         24                         13                          13                         17                       NaN                         22                         31                       NaN                     15                     12                    NaN                    NaN                    NaN                    NaN                    NaN                    8.4                NaN                20.7                NaN                  40                       NaN                         28                   NaN                     34                     35                    26                     17                     37                     32                         8                        NaN                     NaN                  NaN                   NaN                    21                  6                12                NaN                 23                   36                   NaN                   NaN                       12                         NaN                           21                          NaN                     NaN                   NaN                    NaN                      NaN                       NaN                       NaN                       NaN                       NaN                      NaN                    NaN                   18                 NaN                 18                   15                   17                   15                    20                     18                  NaN                 NaN                 21                   NaN                      NaN                   NaN                    NaN                      NaN                      NaN                    5.3                   NaN                   6.3                   18.5                      NaN                           18                          23                         15                       31                        8                       39                          9                         22                         46                        20                     NaN                         24                            20                          16                        26                         22                            31                            32                           19                           40                             NaN                              40                              30                            NaN                             NaN                           NaN                       23                        13                           NaN                        NaN                       NaN                          NaN                           5.3                         NaN                      NaN                      NaN                    NaN                   NaN                    NaN                       NaN                       NaN                    11.5                     6.4                      NaN                     10                  NaN                  NaN                NaN                NaN                NaN                 20                 20                   10                  NaN                NaN                   10                  10                   10                NaN                10                  NaN                  10                   NaN                  NaN                   NaN                  NaN              NaN                 30                NaN             40                 NaN                    NaN                      35                          25                      39.3                     36.1                    34.5                    39.8                     NaN                      NaN                         20                        NaN                          21                         20                    30                      14                        NaN                           15                         19                      NaN                    NaN                      NaN                      NaN                      NaN                        11                      NaN                    NaN        
    01-Jan-1985 01:00:00               NaN                       NaN                  NaN                 NaN                 NaN                 NaN                    30                       NaN                    40                  NaN               NaN                    12                       10                        30                     20                         30                           30                          20                           60                          NaN                      NaN                      NaN                      30                    NaN                    NaN                     20                    20                   NaN                    NaN                   NaN                    NaN                      120                           140                            80                           90                            10                           120                          NaN                           90                            60                          50                          110                            80                           100                           NaN                           NaN                           NaN                            30                           100                        30                     NaN                         10                      20                    10                       10                        60                       NaN                          20                          NaN                           10                          20                        NaN                           10                           20                         NaN                          20                           20                              30                             NaN                              10                             20                             NaN                             10                              30                              NaN                          40                         20                          60                          10                         NaN                        40                       NaN                       40                        50                           NaN                          NaN                              10                               10                               20                              30                             20                          NaN                            NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                              10                             NaN                             NaN                             NaN                             NaN                            NaN                          NaN                          NaN                         NaN                       NaN                      NaN                    20                     20                        NaN                           NaN                          NaN                       NaN                        NaN                        NaN                         20                        NaN                      NaN                     NaN                        10                       8                        7                      NaN                   18                   NaN                   NaN                     NaN                     NaN                     NaN                     NaN                     NaN                     NaN                     NaN                        NaN                          28                           30                           34                          50                          30                                 34                                          41                              10                 NaN                      18                             8                        NaN                       NaN                        9                     NaN                         9                      10                   NaN                 20.1                  NaN                   NaN                   NaN                   NaN                   NaN                   NaN                  NaN                   9                   8                  NaN                   NaN                   NaN                   NaN                  NaN                 NaN                 NaN                   NaN                       18                    NaN                NaN                 19                  20                   NaN                 NaN                 NaN                  NaN                   10                  NaN                  NaN                   10                  NaN                 NaN                 NaN                  NaN                 NaN                  NaN                    6                      NaN                        NaN                         NaN                      11                   NaN                   10                  21                     10                     NaN                    NaN                     NaN                       NaN                        NaN                    NaN                     NaN                          15                            8                        15                         15                          35                          NaN                        NaN                       35                            8                          20                        17                         NaN                         NaN                           NaN                           NaN                        NaN                          30                           43                         40                         NaN                         NaN                         NaN                          NaN                         NaN                       NaN                    NaN                   NaN                     NaN                     NaN                    NaN                  6.9                  NaN                    NaN                        11                      NaN                     NaN                     6                    NaN                    NaN                    NaN                    NaN                  NaN                 NaN                 NaN                   NaN                    NaN                   6.3                       NaN                         25                         15                          13                         17                       NaN                         24                         34                       NaN                     19                      9                      7                    NaN                    NaN                    NaN                    NaN                   10.6                NaN                31.8                NaN                  40                       NaN                         28                   NaN                     35                     36                    27                     20                     38                     31                        12                        NaN                     NaN                  NaN                   NaN                    21                  6                11                NaN                 32                   36                   NaN                   NaN                       12                         NaN                           20                          NaN                     NaN                   NaN                    NaN                      NaN                       NaN                       NaN                       NaN                       NaN                      NaN                    NaN                   18                 NaN                 18                   19                   15                   12                    20                     15                  NaN                 NaN                 16                   NaN                      NaN                   NaN                    NaN                      NaN                      NaN                    6.3                   NaN                   6.3                   18.5                      NaN                           19                          24                         16                       33                        9                       35                         10                         22                         44                        18                     NaN                         25                            25                          17                        24                         24                            36                            33                           18                           30                             NaN                              40                              30                            NaN                             NaN                           NaN                       23                        19                           NaN                        NaN                       NaN                          NaN                           5.3                         NaN                      NaN                      NaN                    NaN                   NaN                    NaN                       NaN                       NaN                    15.1                     6.1                      NaN                     10                  NaN                  NaN                 10                NaN                NaN                 20                 20                   10                  NaN                NaN                   10                  10                   10                NaN                10                  NaN                  10                   NaN                  NaN                   NaN                  NaN              NaN                 20                NaN             40                 NaN                    NaN                      32                          25                      34.5                     32.9                    29.2                    39.8                     NaN                      NaN                         15                          6                          21                         20                    20                      18                        NaN                           10                         20                      NaN                    NaN                      NaN                      NaN                      NaN                       NaN                      NaN                    NaN        
      ⋮

In this format you can easily plot the raw data by using the stackedplot function. This plot shows NO2 concentrations for each site as a function of time.

stackedplot(NO2bySite)

Figure contains an object of type stackedplot.

To create a timetable that is also a pivot table, use retime to calculate annual means.

meanNO2bySiteTT = retime(NO2bySite,"yearly","mean")
meanNO2bySiteTT=5×442 timetable
     Timestamp     Alaska_KenaiPeninsula_1004    Arizona_Apache_10    Arizona_Apache_11    Arizona_Apache_7    Arizona_Apache_8    Arizona_Apache_9    Arizona_Maricopa_3002    Arizona_Maricopa_3003    Arizona_Pima_1011    Arizona_Pima_19    Arizona_Pima_2    Arkansas_Pulaski_1002    California_Alameda_1001    California_Alameda_3    California_Butte_2    California_ContraCosta_1002    California_ContraCosta_2    California_ContraCosta_3    California_ContraCosta_3001    California_ElDorado_9    California_Fresno_241    California_Fresno_242    California_Fresno_5    California_Fresno_6    California_Fresno_7    California_Kern_232    California_Kern_4    California_Kern_5001    California_Kern_6    California_Kern_6001    California_Kern_7    California_LosAngeles_1002    California_LosAngeles_1103    California_LosAngeles_1105    California_LosAngeles_113    California_LosAngeles_1201    California_LosAngeles_1301    California_LosAngeles_16    California_LosAngeles_1601    California_LosAngeles_1701    California_LosAngeles_2    California_LosAngeles_2005    California_LosAngeles_2401    California_LosAngeles_4002    California_LosAngeles_4101    California_LosAngeles_5001    California_LosAngeles_6002    California_LosAngeles_7001    California_LosAngeles_8001    California_Marin_1    California_Mendocino_7    California_Monterey_1002    California_Napa_3    California_Orange_1    California_Orange_1002    California_Orange_5001    California_Plumas_1001    California_Riverside_5001    California_Riverside_6001    California_Riverside_8001    California_Sacramento_1    California_Sacramento_10    California_Sacramento_1001    California_Sacramento_2    California_Sacramento_5002    California_Sacramento_6    California_SanBernardino_1    California_SanBernardino_1004    California_SanBernardino_12    California_SanBernardino_2002    California_SanBernardino_3    California_SanBernardino_4001    California_SanBernardino_6    California_SanBernardino_7002    California_SanBernardino_9004    California_SanDiego_1    California_SanDiego_1002    California_SanDiego_1004    California_SanDiego_1006    California_SanDiego_1007    California_SanDiego_3    California_SanDiego_5    California_SanDiego_6    California_SanFrancisco_4    California_SanFrancisco_5    California_SanJoaquin_1002    California_SanLuisObispo_1004    California_SanLuisObispo_2001    California_SanLuisObispo_2002    California_SanLuisObispo_4001    California_SanMateo_1001    California_SantaBarbara_10    California_SantaBarbara_1010    California_SantaBarbara_1011    California_SantaBarbara_1012    California_SantaBarbara_1013    California_SantaBarbara_1014    California_SantaBarbara_1015    California_SantaBarbara_1016    California_SantaBarbara_1017    California_SantaBarbara_1018    California_SantaBarbara_1019    California_SantaBarbara_1020    California_SantaBarbara_1021    California_SantaBarbara_1025    California_SantaBarbara_1026    California_SantaBarbara_1027    California_SantaBarbara_1030    California_SantaBarbara_2002    California_SantaBarbara_2004    California_SantaBarbara_2005    California_SantaBarbara_4002    California_SantaBarbara_4003    California_SantaBarbara_4004    California_SantaBarbara_5001    California_SantaBarbara_8    California_SantaBarbara_9    California_SantaClara_2004    California_SantaCruz_3    California_Shasta_1001    California_Shasta_6    California_Solano_4    California_Sonoma_3    California_Stanislaus_1003    California_Stanislaus_1004    California_Stanislaus_5    California_Tulare_2002    California_Ventura_1003    California_Ventura_2002    California_Ventura_2003    California_Ventura_3001    California_Ventura_5    California_Ventura_6    California_Ventura_7001    Colorado_Adams_3001    Colorado_Arapahoe_1002    Colorado_Arapahoe_3    Colorado_Denver_2    Colorado_ElPaso_4    Colorado_ElPaso_6001    Colorado_ElPaso_6003    Colorado_ElPaso_6004    Colorado_ElPaso_6005    Colorado_ElPaso_6006    Colorado_ElPaso_6009    Colorado_ElPaso_6011    Colorado_ElPaso_6013    Connecticut_Fairfield_113    Connecticut_Fairfield_123    Connecticut_Hartford_1003    Connecticut_NewHaven_1123    Delaware_NewCastle_2002    Delaware_NewCastle_3001    DistrictOfColumbia_DistrictofColumbia_17    DistrictOfColumbia_DistrictofColumbia_25    Florida_Duval_32    Florida_Duval_70    Florida_Hillsborough_1052    Florida_Hillsborough_1055    Florida_Miami_Dade_27    Florida_Miami_Dade_4002    Florida_Orange_2002    Florida_PalmBeach_1004    Florida_PalmBeach_1101    Florida_Pinellas_18    Georgia_DeKalb_2    Georgia_Fulton_48    Illinois_Cook_1002    Illinois_Cook_1102    Illinois_Cook_1601    Illinois_Cook_3101    Illinois_Cook_3102    Illinois_Cook_3601    Illinois_Cook_37    Illinois_Cook_39    Illinois_Cook_40    Illinois_Cook_4002    Illinois_Cook_4003    Illinois_Cook_4004    Illinois_Cook_4005    Illinois_Cook_45    Illinois_Cook_53    Illinois_Cook_63    Illinois_DuPage_1003    Illinois_SaintClair_10    Indiana_Allen_6    Indiana_Clark_3    Indiana_Jasper_2    Indiana_Jasper_3    Indiana_Jefferson_1    Indiana_Knox_4    Indiana_Lake_1016    Indiana_Marion_30    Indiana_Marion_57    Indiana_Marion_65    Indiana_Marion_70    Indiana_Porter_15    Indiana_Porter_16    Indiana_Posey_1    Indiana_Posey_1002    Indiana_Posey_2    Indiana_Spencer_2    Indiana_Spencer_6    Indiana_Sullivan_1    Indiana_Tippecanoe_1001    Indiana_Vanderburgh_1001    Indiana_Vanderburgh_1002    Indiana_Vigo_1012    Kansas_Wyandotte_1    Kentucky_Boone_7    Kentucky_Boyd_10    Kentucky_Campbell_1001    Kentucky_Daviess_5    Kentucky_Fayette_12    Kentucky_Henderson_13    Kentucky_Jefferson_1020    Kentucky_McCracken_1024    Kentucky_Trigg_1    Louisiana_Calcasieu_100    Louisiana_EastBatonRouge_4    Louisiana_Jefferson_1001    Louisiana_Orleans_12    Louisiana_WestBatonRouge_1    Maryland_AnneArundel_19    Maryland_BaltimoreCity_40    Maryland_Baltimore_10    Maryland_Baltimore_3001    Massachusetts_Bristol_1004    Massachusetts_Essex_5    Massachusetts_Hampden_15    Massachusetts_Hampden_16    Massachusetts_Hampden_17    Massachusetts_Hampshire_4002    Massachusetts_Norfolk_8    Massachusetts_Norfolk_9    Massachusetts_Suffolk_1003    Massachusetts_Suffolk_2    Massachusetts_Suffolk_21    Massachusetts_Suffolk_35    Massachusetts_Suffolk_36    Massachusetts_Suffolk_37    Massachusetts_Worcester_20    Michigan_Dickinson_901    Michigan_Dickinson_902    Michigan_Kent_20    Michigan_Midland_940    Michigan_Midland_941    Michigan_Oakland_902    Michigan_Wayne_16    Michigan_Wayne_19    Michigan_Wayne_29    Minnesota_Carlton_6316    Minnesota_Hennepin_50    Minnesota_Hennepin_953    Minnesota_Ramsey_1    Minnesota_Ramsey_3    Minnesota_Ramsey_864    Minnesota_Wright_7    Missouri_Atchison_1    Missouri_Atchison_2    Missouri_Clay_25    Missouri_Clay_5    Missouri_Greene_14    Missouri_Greene_36    Missouri_Jackson_33    Missouri_Platte_23    Missouri_SaintCharles_1002    Missouri_SaintLouis_1    Missouri_SaintLouis_3001    Missouri_SaintLouis_5001    Missouri_SaintLouis_6    Missouri_SaintLouis_7001    Missouri_StLouisCity_72    Missouri_StLouisCity_80    Montana_Missoula_34    Montana_Rosebud_700    Montana_Rosebud_701    Montana_Rosebud_702    Montana_Rosebud_704    Montana_Rosebud_760    Montana_Rosebud_761    Montana_Rosebud_762    Nevada_Clark_1001    Nevada_Clark_16    Nevada_Clark_557    Nevada_Washoe_15    Nevada_Washoe_16    NewHampshire_Hillsborough_16    NewJersey_Bergen_1    NewJersey_Camden_3    NewJersey_Essex_1003    NewJersey_Essex_11    NewJersey_Hudson_6    NewJersey_Morris_3001    NewJersey_Union_4    NewJersey_Union_5001    NewMexico_Bernalillo_15    NewMexico_Bernalillo_23    NewMexico_Catron_1    NewMexico_Eddy_3    NewMexico_SanJuan_14    NewYork_Bronx_74    NewYork_Erie_2    NewYork_Erie_5    NewYork_Essex_5    NewYork_Nassau_5    NewYork_NewYork_10    NewYork_NewYork_56    NewYork_NewYork_63    NorthCarolina_Forsyth_22    NorthCarolina_Forsyth_7    NorthCarolina_Mecklenburg_34    NorthCarolina_Wake_14    NorthDakota_Burke_1    NorthDakota_Dunn_3    NorthDakota_Mercer_1    NorthDakota_Mercer_101    NorthDakota_Mercer_102    NorthDakota_Mercer_103    NorthDakota_Mercer_104    NorthDakota_Oliver_101    NorthDakota_Oliver_2    Ohio_Cuyahoga_2003    Ohio_Cuyahoga_33    Ohio_Cuyahoga_43    Ohio_Franklin_4    Ohio_Hamilton_1013    Ohio_Hamilton_35    Ohio_Hamilton_4002    Ohio_Jefferson_1012    Ohio_Montgomery_29    Ohio_Pickaway_1    Ohio_Pickaway_1001    Ohio_Stark_16    Oklahoma_Cleveland_44    Oklahoma_Cleveland_49    Oklahoma_Kay_600    Oklahoma_Muskogee_167    Oklahoma_Oklahoma_1037    Oklahoma_Oklahoma_33    Oklahoma_Tulsa_127    Oklahoma_Tulsa_174    Oklahoma_Tulsa_191    Oregon_Multnomah_80    Pennsylvania_Allegheny_3    Pennsylvania_Allegheny_31    Pennsylvania_Allegheny_8    Pennsylvania_Beaver_14    Pennsylvania_Berks_9    Pennsylvania_Blair_801    Pennsylvania_Bucks_12    Pennsylvania_Cambria_11    Pennsylvania_Dauphin_401    Pennsylvania_Delaware_2    Pennsylvania_Erie_10    Pennsylvania_Erie_3    Pennsylvania_Lackawanna_2006    Pennsylvania_Lancaster_7    Pennsylvania_Lawrence_15    Pennsylvania_Lehigh_4    Pennsylvania_Luzerne_1101    Pennsylvania_Montgomery_13    Pennsylvania_Northampton_17    Pennsylvania_Perry_301    Pennsylvania_Philadelphia_22    Pennsylvania_Philadelphia_23    Pennsylvania_Philadelphia_29    Pennsylvania_Philadelphia_4    Pennsylvania_Philadelphia_47    Pennsylvania_Washington_200    Pennsylvania_Washington_5    Pennsylvania_York_8    RhodeIsland_Providence_12    RhodeIsland_Providence_19    SouthCarolina_Aiken_3    SouthCarolina_Barnwell_1    SouthCarolina_Lexington_5    SouthCarolina_Richland_1006    Tennessee_Bradley_102    Tennessee_Davidson_10    Tennessee_Davidson_11    Tennessee_Giles_1    Tennessee_Maury_106    Tennessee_McMinn_101    Tennessee_Rutherford_101    Tennessee_Shelby_24    Tennessee_Sullivan_7    Tennessee_Sullivan_9    Tennessee_Williamson_103    Texas_Bexar_36    Texas_Brazoria_1003    Texas_Dallas_44    Texas_Dallas_45    Texas_Dallas_55    Texas_Dallas_69    Texas_ElPaso_27    Texas_ElPaso_37    Texas_Galveston_1002    Texas_Gregg_1    Texas_Harris_1034    Texas_Harris_1035    Texas_Harris_1037    Texas_Harris_24    Texas_Harris_26    Texas_Harris_47    Texas_Harris_7001    Texas_Jefferson_9    Texas_Orange_1001    Texas_Tarrant_1002    Texas_Tarrant_1003    Texas_Travis_17    Utah_Davis_1    Utah_SaltLake_3001    Utah_Utah_2    Utah_Weber_1    Vermont_Chittenden_3    Vermont_Rutland_2    Virginia_AlexandriaCity_9    Virginia_Arlington_20    Virginia_FairfaxCity_5    Virginia_Fairfax_1004    Virginia_Fairfax_18    Virginia_Fairfax_5001    Virginia_Henrico_14    Virginia_NorfolkCity_23    Virginia_RichmondCity_21    Virginia_Roanoke_1004    Virginia_VirginiaBeachCity_7    Washington_King_80    Washington_King_82    WestVirginia_Cabell_6    WestVirginia_Greenbrier_1    WestVirginia_Hancock_1004    WestVirginia_Kanawha_4    WestVirginia_Ohio_7    Wisconsin_Columbia_8    Wisconsin_Kenosha_1001    Wisconsin_Kenosha_16    Wisconsin_Milwaukee_41    Wisconsin_Milwaukee_80    Wisconsin_Rock_1002    Wisconsin_Rock_1004
    ___________    __________________________    _________________    _________________    ________________    ________________    ________________    _____________________    _____________________    _________________    _______________    ______________    _____________________    _______________________    ____________________    __________________    ___________________________    ________________________    ________________________    ___________________________    _____________________    _____________________    _____________________    ___________________    ___________________    ___________________    ___________________    _________________    ____________________    _________________    ____________________    _________________    __________________________    __________________________    __________________________    _________________________    __________________________    __________________________    ________________________    __________________________    __________________________    _______________________    __________________________    __________________________    __________________________    __________________________    __________________________    __________________________    __________________________    __________________________    __________________    ______________________    ________________________    _________________    ___________________    ______________________    ______________________    ______________________    _________________________    _________________________    _________________________    _______________________    ________________________    __________________________    _______________________    __________________________    _______________________    __________________________    _____________________________    ___________________________    _____________________________    __________________________    _____________________________    __________________________    _____________________________    _____________________________    _____________________    ________________________    ________________________    ________________________    ________________________    _____________________    _____________________    _____________________    _________________________    _________________________    __________________________    _____________________________    _____________________________    _____________________________    _____________________________    ________________________    __________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    _________________________    _________________________    __________________________    ______________________    ______________________    ___________________    ___________________    ___________________    __________________________    __________________________    _______________________    ______________________    _______________________    _______________________    _______________________    _______________________    ____________________    ____________________    _______________________    ___________________    ______________________    ___________________    _________________    _________________    ____________________    ____________________    ____________________    ____________________    ____________________    ____________________    ____________________    ____________________    _________________________    _________________________    _________________________    _________________________    _______________________    _______________________    ________________________________________    ________________________________________    ________________    ________________    _________________________    _________________________    _____________________    _______________________    ___________________    ______________________    ______________________    ___________________    ________________    _________________    __________________    __________________    __________________    __________________    __________________    __________________    ________________    ________________    ________________    __________________    __________________    __________________    __________________    ________________    ________________    ________________    ____________________    ______________________    _______________    _______________    ________________    ________________    ___________________    ______________    _________________    _________________    _________________    _________________    _________________    _________________    _________________    _______________    __________________    _______________    _________________    _________________    __________________    _______________________    ________________________    ________________________    _________________    __________________    ________________    ________________    ______________________    __________________    ___________________    _____________________    _______________________    _______________________    ________________    _______________________    __________________________    ________________________    ____________________    __________________________    _______________________    _________________________    _____________________    _______________________    __________________________    _____________________    ________________________    ________________________    ________________________    ____________________________    _______________________    _______________________    __________________________    _______________________    ________________________    ________________________    ________________________    ________________________    __________________________    ______________________    ______________________    ________________    ____________________    ____________________    ____________________    _________________    _________________    _________________    ______________________    _____________________    ______________________    __________________    __________________    ____________________    __________________    ___________________    ___________________    ________________    _______________    __________________    __________________    ___________________    __________________    __________________________    _____________________    ________________________    ________________________    _____________________    ________________________    _______________________    _______________________    ___________________    ___________________    ___________________    ___________________    ___________________    ___________________    ___________________    ___________________    _________________    _______________    ________________    ________________    ________________    ____________________________    __________________    __________________    ____________________    __________________    __________________    _____________________    _________________    ____________________    _______________________    _______________________    __________________    ________________    ____________________    ________________    ______________    ______________    _______________    ________________    __________________    __________________    __________________    ________________________    _______________________    ____________________________    _____________________    ___________________    __________________    ____________________    ______________________    ______________________    ______________________    ______________________    ______________________    ____________________    __________________    ________________    ________________    _______________    __________________    ________________    __________________    ___________________    __________________    _______________    __________________    _____________    _____________________    _____________________    ________________    _____________________    ______________________    ____________________    __________________    __________________    __________________    ___________________    ________________________    _________________________    ________________________    ______________________    ____________________    ______________________    _____________________    _______________________    ________________________    _______________________    ____________________    ___________________    ____________________________    ________________________    ________________________    _____________________    _________________________    __________________________    ___________________________    ______________________    ____________________________    ____________________________    ____________________________    ___________________________    ____________________________    ___________________________    _________________________    ___________________    _________________________    _________________________    _____________________    ________________________    _________________________    ___________________________    _____________________    _____________________    _____________________    _________________    ___________________    ____________________    ________________________    ___________________    ____________________    ____________________    ________________________    ______________    ___________________    _______________    _______________    _______________    _______________    _______________    _______________    ____________________    _____________    _________________    _________________    _________________    _______________    _______________    _______________    _________________    _________________    _________________    __________________    __________________    _______________    ____________    __________________    ___________    ____________    ____________________    _________________    _________________________    _____________________    ______________________    _____________________    ___________________    _____________________    ___________________    _______________________    ________________________    _____________________    ____________________________    __________________    __________________    _____________________    _________________________    _________________________    ______________________    ___________________    ____________________    ______________________    ____________________    ______________________    ______________________    ___________________    ___________________

    01-Jan-1985                 NaN                   8.4406               8.4264                 7.75              5.9138              6.7021                24.546                   15.514                 18.531                 NaN             24.518               11.748                    26.308                    22.396                  15.87                    15.428                        23.182                      21.806                       35.881                      15.142                      NaN                      NaN                  31.365                  19.75                 20.952                 26.921                30.993                    NaN                   NaN                    NaN                   NaN                    57.401                        59.965                        58.399                       38.492                        39.672                        52.548                          NaN                       53.377                        54.147                      50.289                       50.162                        47.958                        50.114                           NaN                           NaN                           NaN                        17.384                        43.92                     24.229                    NaN                      15.855                  18.447                43.104                   29.302                    42.811                       NaN                     20.183                          NaN                       35.461                      22.077                         NaN                       18.823                      18.546                          NaN                      20.747                       26.424                         39.996                             NaN                          37.844                          38.204                            NaN                          13.073                         21.232                              NaN                       27.568                     27.879                      32.718                      17.111                        NaN                     31.908                      NaN                   25.372                     28.254                          NaN                        20.258                         11.732                           15.251                           17.762                           13.598                          22.81                          NaN                            NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                          18.188                             NaN                          11.797                             NaN                             NaN                             NaN                             NaN                        15.398                        29.84                           NaN                         NaN                    11.09                      NaN                 20.359                 17.994                        NaN                           NaN                      22.091                       22.5                       NaN                        NaN                     20.857                     19.645                    11.459                     NaN                   27.996                   28.659                   19.921                     NaN                47.934               23.989                    NaN                     NaN                     NaN                     NaN                     NaN                     NaN                     NaN                     NaN                       NaN                       27.085                       21.763                        30.71                      29.012                      25.01                               36.44                                      28.321                           16.73              11.309                  19.458                       16.542                       11.3                    17.428                   11.708                      NaN                    14.395                  17.472                15.937              27.001                22.592                24.021                17.317                34.109                   NaN                   NaN               27.304                34.9              42.464               27.823                   NaN                   NaN                   NaN               24.622              24.338                 NaN                   NaN                   22.475                   NaN             16.508              12.728              11.049               11.159                  NaN                NaN               21.894               20.817                  NaN               18.893               13.242               13.404                 NaN               24.704                 NaN              10.191               10.965                10.863                     NaN                       12.02                      14.059                  12.323                   NaN               13.912              17.453                 21.639                  13.276                18.625                  25.127                    23.747                     16.189                  7.3081                 12.353                       24.902                       16.618                    24.532                     22.192                      20.122                      35.846                      18.22                    26.679                       18.263                     22.122                     25.231                         NaN                         NaN                           NaN                          NaN                        NaN                       24.399                      39.768                      30.652                         NaN                         NaN                      25.344                          NaN                      11.918                    9.3198                    NaN                   NaN                     NaN                  16.595                8.6867                22.76                  NaN                     NaN                   18.871                       NaN                     NaN                21.701                    NaN                    NaN                   NaN                    NaN                16.102             10.219               8.6515                   NaN                25.521                  15.02                    13.793                     22.332                      20.21                      19.638                    15.016                        NaN                     52.023                     23.916                      NaN                 12.593                 12.093                 8.9425                 10.568                 9.4729                 8.9321                 9.3806                 33.51                 NaN              27.971                 NaN              27.348                       NaN                     33.968                27.979                 30.159                 33.573                 32.32                 15.408                 42.927                 23.856                   19.197                        NaN                   7.2632                  NaN                17.908                32.466             19.512             24.49            6.1648              33.617               42.346                   NaN                   NaN                   15.117                        NaN                        19.708                         NaN                     NaN                 6.1797                 9.0852                   7.6016                    8.3062                    7.0871                    9.0084                    7.6155                      NaN                    NaN               29.908              22.072             25.342               18.026               29.099               29.067                19.529                 22.141                 NaN                  NaN             19.598                19.67                      NaN                    NaN                   NaN                    13.974                    17.06                 16.525                12.774                20.443                 19.25                       NaN                      29.692                       27.063                     23.138                   23.368                   18.04                    25.828                    20.217                      22.045                     24.373                    17.031                    NaN                       23.05                        19.274                      21.778                    19.444                     21.536                        23.813                        21.589                       10.948                       31.667                             NaN                          34.406                         33.719                          36.223                         19.809                        18.619                    25.262                    26.242                          NaN                        NaN                      8.916                         NaN                        7.8505                      13.259                      NaN                      NaN                  13.02                   NaN                  12.057                       NaN                   18.537                   19.75                  17.573                       NaN                 16.809              15.465               22.288             18.562             15.853                NaN             24.654             19.713                14.71               11.741             21.096               25.421               28.928              17.341             15.587             23.676              14.588               14.603               11.179                20.275                 23.15                 NaN               NaN             38.119            31.138          31.073              16.922                   NaN                   29.671                     24.991                    23.347                   25.148                   21.04                  25.784                     NaN                      NaN                       23.05                    14.758                       18.108                     19.799                34.428                 16.663                     8.6705                       18.629                       23.72                  17.997                  11.788                   14.625                   14.075                   18.757                    26.559                  14.536                 13.956       
    01-Jan-1986                 NaN                   7.3333                7.587               6.7857              6.1875              7.6579                   NaN                   10.816                 20.043                 NaN             24.036               12.383                    25.817                    22.413                 15.932                    15.513                        23.238                       22.14                       38.407                      14.519                   19.512                      NaN                  32.125                 16.135                 19.994                 23.927                30.657                    NaN                   NaN                    NaN                   NaN                    57.422                        61.266                           NaN                       42.167                        32.775                        52.877                          NaN                       52.982                        55.924                      49.656                       51.265                         50.39                        52.939                           NaN                        42.075                           NaN                        15.945                          NaN                     25.236                    NaN                        15.4                  18.873                44.647                   30.347                    42.358                       NaN                     20.263                          NaN                       32.584                      22.894                         NaN                       14.896                      15.641                          NaN                      17.291                        27.45                         42.873                             NaN                          42.875                             NaN                         16.134                          15.104                         24.178                              NaN                       24.919                     29.698                      34.062                      18.365                        NaN                     32.813                   26.668                   27.248                     23.262                       24.453                         23.66                          11.63                           14.361                           17.025                           13.811                         25.354                          NaN                         11.333                          7.7075                          6.7778                          6.5787                          6.7744                          10.311                             NaN                             NaN                             NaN                             NaN                             NaN                           9.552                             NaN                             NaN                             NaN                          7.2131                          18.304                          13.057                          11.347                          10.897                             NaN                          7.6748                          11.063                         15.74                        22.75                           NaN                         NaN                      NaN                   16.632                 19.264                 17.383                     17.879                           NaN                      24.073                     24.637                       NaN                      29.37                     19.151                     18.612                    11.048                     NaN                      NaN                   29.788                   20.583                     NaN                46.959                  NaN                    NaN                     NaN                     NaN                     NaN                     NaN                     NaN                     NaN                     NaN                       NaN                       26.808                       21.944                       28.921                      29.726                     23.681                              29.263                                      34.748                          15.686                 NaN                  20.731                          NaN                     14.793                    19.395                   13.345                    13.34                    14.855                     NaN                19.216              30.544                22.189                16.758                17.349                31.479                   NaN                   NaN               26.497              31.666              41.484               25.755                22.434                   NaN                   NaN               24.424              23.444                 NaN                   NaN                   23.407                12.409             15.068                 NaN                 NaN               11.764               15.848                NaN                  NaN                19.41                  NaN               21.499                  NaN                  NaN              12.077                  NaN                 NaN              10.722               10.582                9.9393                     NaN                      10.685                      14.285                  10.324                 33.12               13.229              14.944                 21.254                   14.33                 18.87                  21.944                    33.019                     16.472                  6.6789                    NaN                        22.55                       16.568                    25.139                     19.715                      19.405                      35.694                        NaN                    26.736                        23.56                     29.285                     22.306                         NaN                         NaN                        12.952                          NaN                        NaN                       24.827                      33.813                      33.618                         NaN                         NaN                      24.076                       29.656                      12.011                    9.7336                    NaN                   NaN                     NaN                  15.487                19.343               20.231                  NaN                     NaN                   19.528                       NaN                   17.28                21.242                    NaN                    NaN                   NaN                    NaN                16.581             13.038               9.6631                   NaN                   NaN                  14.25                    13.806                     22.082                     20.995                      20.896                    16.037                        NaN                     35.899                     19.872                      NaN                 11.498                 10.498                 9.4051                 10.095                 9.6492                 9.8615                  13.53                   NaN                 NaN              29.201                 NaN              25.467                    17.309                     30.186                27.491                  32.48                 31.747                31.926                 15.752                 31.068                 25.007                    17.85                        NaN                   7.1154                12.82                   NaN                 35.33             20.538              25.2            7.2556              33.792                43.22                48.628                   NaN                   18.296                     10.689                        22.176                         NaN                     NaN                 7.3706                 8.8679                   7.1527                    9.7337                    7.0102                    8.6307                    6.8223                      NaN                 28.067               26.678              21.427             25.933               19.528               29.328               27.169                20.258                 21.602                 NaN                  NaN             18.439               18.795                      NaN                    NaN                11.398                    13.718                   18.592                 16.843                14.262                21.168                19.588                       NaN                       33.32                       26.239                     19.882                   24.299                     NaN                    26.732                    20.047                      22.914                        NaN                    16.394                    NaN                      19.578                        19.133                      22.735                     21.53                     21.121                           NaN                           NaN                       11.541                          NaN                          17.398                          36.348                         33.298                           35.91                         19.827                        19.557                    24.243                     25.42                          NaN                     8.9886                     8.0979                      9.4549                           NaN                      15.236                      NaN                      NaN                 13.783                   NaN                  14.101                       NaN                   25.322                  19.989                  17.213                       NaN                    NaN               15.74               29.374               18.6             17.524             23.369              26.29             19.114                  NaN                  NaN             20.536               26.168                 28.6              17.739             15.729             24.972                 NaN               14.402                  NaN                18.705                22.432                 NaN               NaN             35.334            25.012          27.123              19.013                   NaN                   31.363                     27.049                    24.736                   25.662                  26.251                  24.318                     NaN                      NaN                       22.36                    15.369                       19.215                      19.82                32.476                 17.905                     8.1619                        18.48                      23.496                  18.445                  11.013                   16.914                   30.289                   19.944                    27.538                  13.324                  14.81       

Create a stacked plot of the annual means.

stackedplot(meanNO2bySiteTT)

Figure contains an object of type stackedplot.

You might want to preserve information from the original timetable NO2data in this timetable of results. For example, you might want to add the latitudes and longitudes of the sites to NO2bySite. They were stored for each timestamp in NO2data. But to store them more compactly in this timetable, add them as per-variable custom properties to NO2bySite.

LatLon = groupsummary(NO2data,"SiteID","mode",["Latitude","Longitude"]);
NO2bySite = addprop(NO2bySite,["Latitude","Longitude"],["variable","variable"]);
NO2bySite.Properties.CustomProperties.Latitude(string(LatLon.SiteID)) = LatLon.mode_Latitude';
NO2bySite.Properties.CustomProperties.Longitude(string(LatLon.SiteID)) = LatLon.mode_Longitude';

Moving Means for Data Grouped by Site

To calculate compliance with the second NAAQS standard for NO2 requires a sequence of grouped calculations. By the second standard, a location is out of compliance if the 98th percentile of the 1-hour daily maximum concentrations of NO2, averaged over 3 years, exceeds 100 ppb.

Start with the hourly concentrations of NO2 by site. To find the daily maximum for each site, use the retime function, specifying "max" as the method to find the maximum concentration for each day's worth of data. Then find the 98th percentiles of the daily maximums in each year's worth of data, calling retime a second time. To calculate percentiles, use the findPrctile supporting function referred to in this example.

dailyMax = retime(NO2bySite,"daily","max");
yearlyP98 = retime(dailyMax,"yearly",@(x)findPrctile(x,98))
yearlyP98=5×442 timetable
     Timestamp     Alaska_KenaiPeninsula_1004    Arizona_Apache_10    Arizona_Apache_11    Arizona_Apache_7    Arizona_Apache_8    Arizona_Apache_9    Arizona_Maricopa_3002    Arizona_Maricopa_3003    Arizona_Pima_1011    Arizona_Pima_19    Arizona_Pima_2    Arkansas_Pulaski_1002    California_Alameda_1001    California_Alameda_3    California_Butte_2    California_ContraCosta_1002    California_ContraCosta_2    California_ContraCosta_3    California_ContraCosta_3001    California_ElDorado_9    California_Fresno_241    California_Fresno_242    California_Fresno_5    California_Fresno_6    California_Fresno_7    California_Kern_232    California_Kern_4    California_Kern_5001    California_Kern_6    California_Kern_6001    California_Kern_7    California_LosAngeles_1002    California_LosAngeles_1103    California_LosAngeles_1105    California_LosAngeles_113    California_LosAngeles_1201    California_LosAngeles_1301    California_LosAngeles_16    California_LosAngeles_1601    California_LosAngeles_1701    California_LosAngeles_2    California_LosAngeles_2005    California_LosAngeles_2401    California_LosAngeles_4002    California_LosAngeles_4101    California_LosAngeles_5001    California_LosAngeles_6002    California_LosAngeles_7001    California_LosAngeles_8001    California_Marin_1    California_Mendocino_7    California_Monterey_1002    California_Napa_3    California_Orange_1    California_Orange_1002    California_Orange_5001    California_Plumas_1001    California_Riverside_5001    California_Riverside_6001    California_Riverside_8001    California_Sacramento_1    California_Sacramento_10    California_Sacramento_1001    California_Sacramento_2    California_Sacramento_5002    California_Sacramento_6    California_SanBernardino_1    California_SanBernardino_1004    California_SanBernardino_12    California_SanBernardino_2002    California_SanBernardino_3    California_SanBernardino_4001    California_SanBernardino_6    California_SanBernardino_7002    California_SanBernardino_9004    California_SanDiego_1    California_SanDiego_1002    California_SanDiego_1004    California_SanDiego_1006    California_SanDiego_1007    California_SanDiego_3    California_SanDiego_5    California_SanDiego_6    California_SanFrancisco_4    California_SanFrancisco_5    California_SanJoaquin_1002    California_SanLuisObispo_1004    California_SanLuisObispo_2001    California_SanLuisObispo_2002    California_SanLuisObispo_4001    California_SanMateo_1001    California_SantaBarbara_10    California_SantaBarbara_1010    California_SantaBarbara_1011    California_SantaBarbara_1012    California_SantaBarbara_1013    California_SantaBarbara_1014    California_SantaBarbara_1015    California_SantaBarbara_1016    California_SantaBarbara_1017    California_SantaBarbara_1018    California_SantaBarbara_1019    California_SantaBarbara_1020    California_SantaBarbara_1021    California_SantaBarbara_1025    California_SantaBarbara_1026    California_SantaBarbara_1027    California_SantaBarbara_1030    California_SantaBarbara_2002    California_SantaBarbara_2004    California_SantaBarbara_2005    California_SantaBarbara_4002    California_SantaBarbara_4003    California_SantaBarbara_4004    California_SantaBarbara_5001    California_SantaBarbara_8    California_SantaBarbara_9    California_SantaClara_2004    California_SantaCruz_3    California_Shasta_1001    California_Shasta_6    California_Solano_4    California_Sonoma_3    California_Stanislaus_1003    California_Stanislaus_1004    California_Stanislaus_5    California_Tulare_2002    California_Ventura_1003    California_Ventura_2002    California_Ventura_2003    California_Ventura_3001    California_Ventura_5    California_Ventura_6    California_Ventura_7001    Colorado_Adams_3001    Colorado_Arapahoe_1002    Colorado_Arapahoe_3    Colorado_Denver_2    Colorado_ElPaso_4    Colorado_ElPaso_6001    Colorado_ElPaso_6003    Colorado_ElPaso_6004    Colorado_ElPaso_6005    Colorado_ElPaso_6006    Colorado_ElPaso_6009    Colorado_ElPaso_6011    Colorado_ElPaso_6013    Connecticut_Fairfield_113    Connecticut_Fairfield_123    Connecticut_Hartford_1003    Connecticut_NewHaven_1123    Delaware_NewCastle_2002    Delaware_NewCastle_3001    DistrictOfColumbia_DistrictofColumbia_17    DistrictOfColumbia_DistrictofColumbia_25    Florida_Duval_32    Florida_Duval_70    Florida_Hillsborough_1052    Florida_Hillsborough_1055    Florida_Miami_Dade_27    Florida_Miami_Dade_4002    Florida_Orange_2002    Florida_PalmBeach_1004    Florida_PalmBeach_1101    Florida_Pinellas_18    Georgia_DeKalb_2    Georgia_Fulton_48    Illinois_Cook_1002    Illinois_Cook_1102    Illinois_Cook_1601    Illinois_Cook_3101    Illinois_Cook_3102    Illinois_Cook_3601    Illinois_Cook_37    Illinois_Cook_39    Illinois_Cook_40    Illinois_Cook_4002    Illinois_Cook_4003    Illinois_Cook_4004    Illinois_Cook_4005    Illinois_Cook_45    Illinois_Cook_53    Illinois_Cook_63    Illinois_DuPage_1003    Illinois_SaintClair_10    Indiana_Allen_6    Indiana_Clark_3    Indiana_Jasper_2    Indiana_Jasper_3    Indiana_Jefferson_1    Indiana_Knox_4    Indiana_Lake_1016    Indiana_Marion_30    Indiana_Marion_57    Indiana_Marion_65    Indiana_Marion_70    Indiana_Porter_15    Indiana_Porter_16    Indiana_Posey_1    Indiana_Posey_1002    Indiana_Posey_2    Indiana_Spencer_2    Indiana_Spencer_6    Indiana_Sullivan_1    Indiana_Tippecanoe_1001    Indiana_Vanderburgh_1001    Indiana_Vanderburgh_1002    Indiana_Vigo_1012    Kansas_Wyandotte_1    Kentucky_Boone_7    Kentucky_Boyd_10    Kentucky_Campbell_1001    Kentucky_Daviess_5    Kentucky_Fayette_12    Kentucky_Henderson_13    Kentucky_Jefferson_1020    Kentucky_McCracken_1024    Kentucky_Trigg_1    Louisiana_Calcasieu_100    Louisiana_EastBatonRouge_4    Louisiana_Jefferson_1001    Louisiana_Orleans_12    Louisiana_WestBatonRouge_1    Maryland_AnneArundel_19    Maryland_BaltimoreCity_40    Maryland_Baltimore_10    Maryland_Baltimore_3001    Massachusetts_Bristol_1004    Massachusetts_Essex_5    Massachusetts_Hampden_15    Massachusetts_Hampden_16    Massachusetts_Hampden_17    Massachusetts_Hampshire_4002    Massachusetts_Norfolk_8    Massachusetts_Norfolk_9    Massachusetts_Suffolk_1003    Massachusetts_Suffolk_2    Massachusetts_Suffolk_21    Massachusetts_Suffolk_35    Massachusetts_Suffolk_36    Massachusetts_Suffolk_37    Massachusetts_Worcester_20    Michigan_Dickinson_901    Michigan_Dickinson_902    Michigan_Kent_20    Michigan_Midland_940    Michigan_Midland_941    Michigan_Oakland_902    Michigan_Wayne_16    Michigan_Wayne_19    Michigan_Wayne_29    Minnesota_Carlton_6316    Minnesota_Hennepin_50    Minnesota_Hennepin_953    Minnesota_Ramsey_1    Minnesota_Ramsey_3    Minnesota_Ramsey_864    Minnesota_Wright_7    Missouri_Atchison_1    Missouri_Atchison_2    Missouri_Clay_25    Missouri_Clay_5    Missouri_Greene_14    Missouri_Greene_36    Missouri_Jackson_33    Missouri_Platte_23    Missouri_SaintCharles_1002    Missouri_SaintLouis_1    Missouri_SaintLouis_3001    Missouri_SaintLouis_5001    Missouri_SaintLouis_6    Missouri_SaintLouis_7001    Missouri_StLouisCity_72    Missouri_StLouisCity_80    Montana_Missoula_34    Montana_Rosebud_700    Montana_Rosebud_701    Montana_Rosebud_702    Montana_Rosebud_704    Montana_Rosebud_760    Montana_Rosebud_761    Montana_Rosebud_762    Nevada_Clark_1001    Nevada_Clark_16    Nevada_Clark_557    Nevada_Washoe_15    Nevada_Washoe_16    NewHampshire_Hillsborough_16    NewJersey_Bergen_1    NewJersey_Camden_3    NewJersey_Essex_1003    NewJersey_Essex_11    NewJersey_Hudson_6    NewJersey_Morris_3001    NewJersey_Union_4    NewJersey_Union_5001    NewMexico_Bernalillo_15    NewMexico_Bernalillo_23    NewMexico_Catron_1    NewMexico_Eddy_3    NewMexico_SanJuan_14    NewYork_Bronx_74    NewYork_Erie_2    NewYork_Erie_5    NewYork_Essex_5    NewYork_Nassau_5    NewYork_NewYork_10    NewYork_NewYork_56    NewYork_NewYork_63    NorthCarolina_Forsyth_22    NorthCarolina_Forsyth_7    NorthCarolina_Mecklenburg_34    NorthCarolina_Wake_14    NorthDakota_Burke_1    NorthDakota_Dunn_3    NorthDakota_Mercer_1    NorthDakota_Mercer_101    NorthDakota_Mercer_102    NorthDakota_Mercer_103    NorthDakota_Mercer_104    NorthDakota_Oliver_101    NorthDakota_Oliver_2    Ohio_Cuyahoga_2003    Ohio_Cuyahoga_33    Ohio_Cuyahoga_43    Ohio_Franklin_4    Ohio_Hamilton_1013    Ohio_Hamilton_35    Ohio_Hamilton_4002    Ohio_Jefferson_1012    Ohio_Montgomery_29    Ohio_Pickaway_1    Ohio_Pickaway_1001    Ohio_Stark_16    Oklahoma_Cleveland_44    Oklahoma_Cleveland_49    Oklahoma_Kay_600    Oklahoma_Muskogee_167    Oklahoma_Oklahoma_1037    Oklahoma_Oklahoma_33    Oklahoma_Tulsa_127    Oklahoma_Tulsa_174    Oklahoma_Tulsa_191    Oregon_Multnomah_80    Pennsylvania_Allegheny_3    Pennsylvania_Allegheny_31    Pennsylvania_Allegheny_8    Pennsylvania_Beaver_14    Pennsylvania_Berks_9    Pennsylvania_Blair_801    Pennsylvania_Bucks_12    Pennsylvania_Cambria_11    Pennsylvania_Dauphin_401    Pennsylvania_Delaware_2    Pennsylvania_Erie_10    Pennsylvania_Erie_3    Pennsylvania_Lackawanna_2006    Pennsylvania_Lancaster_7    Pennsylvania_Lawrence_15    Pennsylvania_Lehigh_4    Pennsylvania_Luzerne_1101    Pennsylvania_Montgomery_13    Pennsylvania_Northampton_17    Pennsylvania_Perry_301    Pennsylvania_Philadelphia_22    Pennsylvania_Philadelphia_23    Pennsylvania_Philadelphia_29    Pennsylvania_Philadelphia_4    Pennsylvania_Philadelphia_47    Pennsylvania_Washington_200    Pennsylvania_Washington_5    Pennsylvania_York_8    RhodeIsland_Providence_12    RhodeIsland_Providence_19    SouthCarolina_Aiken_3    SouthCarolina_Barnwell_1    SouthCarolina_Lexington_5    SouthCarolina_Richland_1006    Tennessee_Bradley_102    Tennessee_Davidson_10    Tennessee_Davidson_11    Tennessee_Giles_1    Tennessee_Maury_106    Tennessee_McMinn_101    Tennessee_Rutherford_101    Tennessee_Shelby_24    Tennessee_Sullivan_7    Tennessee_Sullivan_9    Tennessee_Williamson_103    Texas_Bexar_36    Texas_Brazoria_1003    Texas_Dallas_44    Texas_Dallas_45    Texas_Dallas_55    Texas_Dallas_69    Texas_ElPaso_27    Texas_ElPaso_37    Texas_Galveston_1002    Texas_Gregg_1    Texas_Harris_1034    Texas_Harris_1035    Texas_Harris_1037    Texas_Harris_24    Texas_Harris_26    Texas_Harris_47    Texas_Harris_7001    Texas_Jefferson_9    Texas_Orange_1001    Texas_Tarrant_1002    Texas_Tarrant_1003    Texas_Travis_17    Utah_Davis_1    Utah_SaltLake_3001    Utah_Utah_2    Utah_Weber_1    Vermont_Chittenden_3    Vermont_Rutland_2    Virginia_AlexandriaCity_9    Virginia_Arlington_20    Virginia_FairfaxCity_5    Virginia_Fairfax_1004    Virginia_Fairfax_18    Virginia_Fairfax_5001    Virginia_Henrico_14    Virginia_NorfolkCity_23    Virginia_RichmondCity_21    Virginia_Roanoke_1004    Virginia_VirginiaBeachCity_7    Washington_King_80    Washington_King_82    WestVirginia_Cabell_6    WestVirginia_Greenbrier_1    WestVirginia_Hancock_1004    WestVirginia_Kanawha_4    WestVirginia_Ohio_7    Wisconsin_Columbia_8    Wisconsin_Kenosha_1001    Wisconsin_Kenosha_16    Wisconsin_Milwaukee_41    Wisconsin_Milwaukee_80    Wisconsin_Rock_1002    Wisconsin_Rock_1004
    ___________    __________________________    _________________    _________________    ________________    ________________    ________________    _____________________    _____________________    _________________    _______________    ______________    _____________________    _______________________    ____________________    __________________    ___________________________    ________________________    ________________________    ___________________________    _____________________    _____________________    _____________________    ___________________    ___________________    ___________________    ___________________    _________________    ____________________    _________________    ____________________    _________________    __________________________    __________________________    __________________________    _________________________    __________________________    __________________________    ________________________    __________________________    __________________________    _______________________    __________________________    __________________________    __________________________    __________________________    __________________________    __________________________    __________________________    __________________________    __________________    ______________________    ________________________    _________________    ___________________    ______________________    ______________________    ______________________    _________________________    _________________________    _________________________    _______________________    ________________________    __________________________    _______________________    __________________________    _______________________    __________________________    _____________________________    ___________________________    _____________________________    __________________________    _____________________________    __________________________    _____________________________    _____________________________    _____________________    ________________________    ________________________    ________________________    ________________________    _____________________    _____________________    _____________________    _________________________    _________________________    __________________________    _____________________________    _____________________________    _____________________________    _____________________________    ________________________    __________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    _________________________    _________________________    __________________________    ______________________    ______________________    ___________________    ___________________    ___________________    __________________________    __________________________    _______________________    ______________________    _______________________    _______________________    _______________________    _______________________    ____________________    ____________________    _______________________    ___________________    ______________________    ___________________    _________________    _________________    ____________________    ____________________    ____________________    ____________________    ____________________    ____________________    ____________________    ____________________    _________________________    _________________________    _________________________    _________________________    _______________________    _______________________    ________________________________________    ________________________________________    ________________    ________________    _________________________    _________________________    _____________________    _______________________    ___________________    ______________________    ______________________    ___________________    ________________    _________________    __________________    __________________    __________________    __________________    __________________    __________________    ________________    ________________    ________________    __________________    __________________    __________________    __________________    ________________    ________________    ________________    ____________________    ______________________    _______________    _______________    ________________    ________________    ___________________    ______________    _________________    _________________    _________________    _________________    _________________    _________________    _________________    _______________    __________________    _______________    _________________    _________________    __________________    _______________________    ________________________    ________________________    _________________    __________________    ________________    ________________    ______________________    __________________    ___________________    _____________________    _______________________    _______________________    ________________    _______________________    __________________________    ________________________    ____________________    __________________________    _______________________    _________________________    _____________________    _______________________    __________________________    _____________________    ________________________    ________________________    ________________________    ____________________________    _______________________    _______________________    __________________________    _______________________    ________________________    ________________________    ________________________    ________________________    __________________________    ______________________    ______________________    ________________    ____________________    ____________________    ____________________    _________________    _________________    _________________    ______________________    _____________________    ______________________    __________________    __________________    ____________________    __________________    ___________________    ___________________    ________________    _______________    __________________    __________________    ___________________    __________________    __________________________    _____________________    ________________________    ________________________    _____________________    ________________________    _______________________    _______________________    ___________________    ___________________    ___________________    ___________________    ___________________    ___________________    ___________________    ___________________    _________________    _______________    ________________    ________________    ________________    ____________________________    __________________    __________________    ____________________    __________________    __________________    _____________________    _________________    ____________________    _______________________    _______________________    __________________    ________________    ____________________    ________________    ______________    ______________    _______________    ________________    __________________    __________________    __________________    ________________________    _______________________    ____________________________    _____________________    ___________________    __________________    ____________________    ______________________    ______________________    ______________________    ______________________    ______________________    ____________________    __________________    ________________    ________________    _______________    __________________    ________________    __________________    ___________________    __________________    _______________    __________________    _____________    _____________________    _____________________    ________________    _____________________    ______________________    ____________________    __________________    __________________    __________________    ___________________    ________________________    _________________________    ________________________    ______________________    ____________________    ______________________    _____________________    _______________________    ________________________    _______________________    ____________________    ___________________    ____________________________    ________________________    ________________________    _____________________    _________________________    __________________________    ___________________________    ______________________    ____________________________    ____________________________    ____________________________    ___________________________    ____________________________    ___________________________    _________________________    ___________________    _________________________    _________________________    _____________________    ________________________    _________________________    ___________________________    _____________________    _____________________    _____________________    _________________    ___________________    ____________________    ________________________    ___________________    ____________________    ____________________    ________________________    ______________    ___________________    _______________    _______________    _______________    _______________    _______________    _______________    ____________________    _____________    _________________    _________________    _________________    _______________    _______________    _______________    _________________    _________________    _________________    __________________    __________________    _______________    ____________    __________________    ___________    ____________    ____________________    _________________    _________________________    _____________________    ______________________    _____________________    ___________________    _____________________    ___________________    _______________________    ________________________    _____________________    ____________________________    __________________    __________________    _____________________    _________________________    _________________________    ______________________    ___________________    ____________________    ______________________    ____________________    ______________________    ______________________    ___________________    ___________________

    01-Jan-1985               NaN                        27                   29                  25                  10                  22                    100                       60                     70                 NaN                80                   53                        100                       80                     60                        50                            80                          80                           120                         60                       NaN                      NaN                     120                     70                     90                    90                    110                   NaN                    NaN                   NaN                    NaN                      190                           230                           230                           180                          140                           210                          NaN                          210                           170                          180                         170                           200                           220                           NaN                           NaN                           NaN                            60                           200                        70                     NaN                         70                      60                    170                     150                       170                       NaN                          70                          NaN                          130                         90                         NaN                           80                           80                         NaN                           90                         110                             130                             NaN                             120                            120                             NaN                             50                             100                              NaN                          110                       120                         150                          70                         NaN                        130                      NaN                      110                        110                          NaN                           80                             30                               50                               70                               50                            100                          NaN                            NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                             NaN                              80                             NaN                              40                             NaN                             NaN                             NaN                             NaN                            60                            90                          NaN                         NaN                        20                      NaN                    70                     80                        NaN                           NaN                          100                       100                        NaN                        NaN                        70                         60                        30                     NaN                       100                      132                      86                      NaN                   160                  106                   NaN                     NaN                     NaN                     NaN                     NaN                     NaN                     NaN                     NaN                        NaN                           84                          66                           88                          80                         160                                103                                          84                              65                  50                      54                            58                        47                        61                        45                     NaN                        72                       65                  52.5                89.7                   97                    91                    63                    93                   NaN                   NaN                   89                  97                 114                   86                   NaN                   NaN                   NaN                   87                  81                 NaN                   NaN                       66                    NaN                 60                 47                  47                    53                 NaN                 NaN                   75                  71                   NaN                   74                   60                   97                 NaN                  96                  NaN                 37                   34                    34                      NaN                         53                          69                       36                   NaN                  56                 115                     65                      49                    55                      83                        98                         68                      25                    39.8                          94                           60                        77                         81                          64                          107                         66                       81                           57                          67                        74                         NaN                         NaN                           NaN                           NaN                        NaN                          71                           99                         87                         NaN                         NaN                          65                          NaN                         37.7                      30.8                   NaN                    NaN                     NaN                      60                  14.8                 81.7                  NaN                    NaN                       66                       NaN                     NaN                    70                    NaN                    NaN                    NaN                    NaN                  65.3                45                   33                   NaN                   127.9                  52.5                       40                         63                         60                          65                        52                        NaN                         172                        79                       NaN                    37                     40                     31                     37                     39                    36.5                    28                   284.6                 NaN              181.6                NaN                 120                       NaN                        117                    94                    109                    108                   119                     73                     124                    82                        75                        NaN                      23                  NaN                    60                   139                 62                80                27                 113                  125                   NaN                   NaN                       54                         NaN                           65                          NaN                     NaN                    11                     26                       25                        29                        20                        36                        28                      NaN                    NaN                  105                  80                  82                  56                   85                   97                     65                    87                  NaN                 NaN                  82                   61                      NaN                   NaN                    NaN                      55.2                     60.5                   67.9                  48.8                    77                  73.2                      NaN                           96                          87                         91                       73                       61                       93                        70                          70                          72                       82                     NaN                         85                            65                          67                        68                         73                            76                             65                          40                          110                             NaN                             110                             100                             90                             88                            56                        77                        75                           NaN                        NaN                         27                         NaN                          39.8                         45                       NaN                      NaN                     64                   NaN                     40                       NaN                        95                      67                    57.5                      NaN                     60                   60                  100                70                 60                 NaN                 80                 80                   60                   30                90                   100                  100                 70                  60                100                  50                  60                    30                   80                    90                  NaN              NaN                130                130            110                  49                    NaN                      90                          90                      74.8                     87.1                      69                     90.2                    NaN                      NaN                         80                        53                           67                         70                    90                     56                         31                           70                          68                      55                     34.5                      81                        77                      66                        82                     54.1                   49.3        
    01-Jan-1986               NaN                        13                   14                  15                  11                  13                    NaN                       43                    114                 NaN                81                   54                        110                       80                     60                        50                            80                          80                           140                         60                        80                      NaN                     140                     50                     80                    80                    100                   NaN                    NaN                   NaN                    NaN                      210                           240                           NaN                           190                          150                           210                          NaN                          180                           180                          180                         180                           180                           210                           NaN                           180                           NaN                            60                           NaN                        80                     NaN                         60                      80                    180                     140                       160                       NaN                          70                          NaN                          120                         90                         NaN                           50                           60                         NaN                           70                         100                             140                             NaN                             150                            NaN                              60                             60                              80                              NaN                          110                       120                         150                          70                         NaN                        140                      130                      120                         80                           80                          100                             30                               50                               70                               50                            100                          NaN                             49                              53                              21                              20                              25                              41                             NaN                             NaN                             NaN                             NaN                             NaN                              34                             NaN                             NaN                             NaN                              29                              70                              40                              30                              30                             NaN                              29                              30                            50                            70                          NaN                         NaN                       NaN                       70                    80                     80                         50                           NaN                          100                        90                        NaN                        110                        70                         70                        30                     NaN                       NaN                      133                      94                      NaN                   155                  NaN                   NaN                     NaN                     NaN                     NaN                     NaN                     NaN                     NaN                     NaN                        NaN                           84                          71                           89                          80                          90                                 85                                         122                              65                 NaN                      61                           NaN                        71                        73                        45                      42                        67                      NaN                  72.2                  94                   87                    42                    60                    85                   NaN                   NaN                   77                  86                 113                   80                    75                   NaN                   NaN                   49                  81                 NaN                   NaN                       75                     50                 66                NaN                 NaN                    60                 130                 NaN                  NaN                  68                   NaN                  237                  NaN                  NaN                  49                 NaN                  NaN                 36                   35                    35                      NaN                         31                          61                       33                 116.8                  46                 115                     55                      48                    75                      77                        98                         76                      21                     NaN                          84                           71                        85                         81                          66                          110                        NaN                       81                           49                         114                        85                         NaN                         NaN                            55                           NaN                        NaN                         121                          122                         93                         NaN                         NaN                          73                          110                         40.8                        35                   NaN                    NaN                     NaN                    39.8                  66.9                 92.9                  NaN                    NaN                       80                       NaN                      53                    71                    NaN                    NaN                    NaN                    NaN                  65.8                52                   32                   NaN                     NaN                  54.1                       45                         75                         84                          67                        58                        NaN                         157                        81                       NaN                    38                     30                     27                     35                     28                      26                    48                     NaN                 NaN              116.3                NaN                 210                        52                         92                    85                    111                    100                   117                     57                     100                    82                        64                        NaN                      15                   40                   NaN                   113                 72               114                20                 101                  138                   127                   NaN                       66                          46                           79                          NaN                     NaN                    20                     28                       24                        38                        21                        31                        23                      NaN                     65                   75                  75                  94                  63                   90                   85                     86                    72                  NaN                 NaN                  69                 61.6                      NaN                   NaN                   63.7                      54.1                     63.2                   64.2                  53.6                  82.3                  97.7                      NaN                          180                          88                         65                       71                      NaN                       98                        67                          72                         NaN                       60                     NaN                         60                            59                          67                        75                         79                           NaN                            NaN                          42                          NaN                              40                             110                              90                             90                             83                            61                        70                        72                           NaN                       33.4                       21.7                          27                           NaN                         62                       NaN                      NaN                     53                   NaN                     57                       NaN                        91                    72.5                      67                      NaN                    NaN                   70                  110                70                 70                  80                100                 70                  NaN                  NaN                80                    90                  110                 70                  60                100                 NaN                  40                   NaN                   70                    80                  NaN              NaN                130                 90             80                  57                    NaN                      85                          85                      80.7                     71.6                    78.6                     72.7                    NaN                      NaN                         75                        55                           68                         80                    90                     70                         29                           67                          72                      62                     35.5                      99                       119                      71                        80                     45.1                   56.8        

Next calculate a moving mean for each site, specifying a three-year window for the moving mean. The smoothdata enables you to apply the movmean function to each variable in yearlyP98.

moving3yearAvg = smoothdata(yearlyP98,"movmean",[years(3) 0])
moving3yearAvg=5×442 timetable
     Timestamp     Alaska_KenaiPeninsula_1004    Arizona_Apache_10    Arizona_Apache_11    Arizona_Apache_7    Arizona_Apache_8    Arizona_Apache_9    Arizona_Maricopa_3002    Arizona_Maricopa_3003    Arizona_Pima_1011    Arizona_Pima_19    Arizona_Pima_2    Arkansas_Pulaski_1002    California_Alameda_1001    California_Alameda_3    California_Butte_2    California_ContraCosta_1002    California_ContraCosta_2    California_ContraCosta_3    California_ContraCosta_3001    California_ElDorado_9    California_Fresno_241    California_Fresno_242    California_Fresno_5    California_Fresno_6    California_Fresno_7    California_Kern_232    California_Kern_4    California_Kern_5001    California_Kern_6    California_Kern_6001    California_Kern_7    California_LosAngeles_1002    California_LosAngeles_1103    California_LosAngeles_1105    California_LosAngeles_113    California_LosAngeles_1201    California_LosAngeles_1301    California_LosAngeles_16    California_LosAngeles_1601    California_LosAngeles_1701    California_LosAngeles_2    California_LosAngeles_2005    California_LosAngeles_2401    California_LosAngeles_4002    California_LosAngeles_4101    California_LosAngeles_5001    California_LosAngeles_6002    California_LosAngeles_7001    California_LosAngeles_8001    California_Marin_1    California_Mendocino_7    California_Monterey_1002    California_Napa_3    California_Orange_1    California_Orange_1002    California_Orange_5001    California_Plumas_1001    California_Riverside_5001    California_Riverside_6001    California_Riverside_8001    California_Sacramento_1    California_Sacramento_10    California_Sacramento_1001    California_Sacramento_2    California_Sacramento_5002    California_Sacramento_6    California_SanBernardino_1    California_SanBernardino_1004    California_SanBernardino_12    California_SanBernardino_2002    California_SanBernardino_3    California_SanBernardino_4001    California_SanBernardino_6    California_SanBernardino_7002    California_SanBernardino_9004    California_SanDiego_1    California_SanDiego_1002    California_SanDiego_1004    California_SanDiego_1006    California_SanDiego_1007    California_SanDiego_3    California_SanDiego_5    California_SanDiego_6    California_SanFrancisco_4    California_SanFrancisco_5    California_SanJoaquin_1002    California_SanLuisObispo_1004    California_SanLuisObispo_2001    California_SanLuisObispo_2002    California_SanLuisObispo_4001    California_SanMateo_1001    California_SantaBarbara_10    California_SantaBarbara_1010    California_SantaBarbara_1011    California_SantaBarbara_1012    California_SantaBarbara_1013    California_SantaBarbara_1014    California_SantaBarbara_1015    California_SantaBarbara_1016    California_SantaBarbara_1017    California_SantaBarbara_1018    California_SantaBarbara_1019    California_SantaBarbara_1020    California_SantaBarbara_1021    California_SantaBarbara_1025    California_SantaBarbara_1026    California_SantaBarbara_1027    California_SantaBarbara_1030    California_SantaBarbara_2002    California_SantaBarbara_2004    California_SantaBarbara_2005    California_SantaBarbara_4002    California_SantaBarbara_4003    California_SantaBarbara_4004    California_SantaBarbara_5001    California_SantaBarbara_8    California_SantaBarbara_9    California_SantaClara_2004    California_SantaCruz_3    California_Shasta_1001    California_Shasta_6    California_Solano_4    California_Sonoma_3    California_Stanislaus_1003    California_Stanislaus_1004    California_Stanislaus_5    California_Tulare_2002    California_Ventura_1003    California_Ventura_2002    California_Ventura_2003    California_Ventura_3001    California_Ventura_5    California_Ventura_6    California_Ventura_7001    Colorado_Adams_3001    Colorado_Arapahoe_1002    Colorado_Arapahoe_3    Colorado_Denver_2    Colorado_ElPaso_4    Colorado_ElPaso_6001    Colorado_ElPaso_6003    Colorado_ElPaso_6004    Colorado_ElPaso_6005    Colorado_ElPaso_6006    Colorado_ElPaso_6009    Colorado_ElPaso_6011    Colorado_ElPaso_6013    Connecticut_Fairfield_113    Connecticut_Fairfield_123    Connecticut_Hartford_1003    Connecticut_NewHaven_1123    Delaware_NewCastle_2002    Delaware_NewCastle_3001    DistrictOfColumbia_DistrictofColumbia_17    DistrictOfColumbia_DistrictofColumbia_25    Florida_Duval_32    Florida_Duval_70    Florida_Hillsborough_1052    Florida_Hillsborough_1055    Florida_Miami_Dade_27    Florida_Miami_Dade_4002    Florida_Orange_2002    Florida_PalmBeach_1004    Florida_PalmBeach_1101    Florida_Pinellas_18    Georgia_DeKalb_2    Georgia_Fulton_48    Illinois_Cook_1002    Illinois_Cook_1102    Illinois_Cook_1601    Illinois_Cook_3101    Illinois_Cook_3102    Illinois_Cook_3601    Illinois_Cook_37    Illinois_Cook_39    Illinois_Cook_40    Illinois_Cook_4002    Illinois_Cook_4003    Illinois_Cook_4004    Illinois_Cook_4005    Illinois_Cook_45    Illinois_Cook_53    Illinois_Cook_63    Illinois_DuPage_1003    Illinois_SaintClair_10    Indiana_Allen_6    Indiana_Clark_3    Indiana_Jasper_2    Indiana_Jasper_3    Indiana_Jefferson_1    Indiana_Knox_4    Indiana_Lake_1016    Indiana_Marion_30    Indiana_Marion_57    Indiana_Marion_65    Indiana_Marion_70    Indiana_Porter_15    Indiana_Porter_16    Indiana_Posey_1    Indiana_Posey_1002    Indiana_Posey_2    Indiana_Spencer_2    Indiana_Spencer_6    Indiana_Sullivan_1    Indiana_Tippecanoe_1001    Indiana_Vanderburgh_1001    Indiana_Vanderburgh_1002    Indiana_Vigo_1012    Kansas_Wyandotte_1    Kentucky_Boone_7    Kentucky_Boyd_10    Kentucky_Campbell_1001    Kentucky_Daviess_5    Kentucky_Fayette_12    Kentucky_Henderson_13    Kentucky_Jefferson_1020    Kentucky_McCracken_1024    Kentucky_Trigg_1    Louisiana_Calcasieu_100    Louisiana_EastBatonRouge_4    Louisiana_Jefferson_1001    Louisiana_Orleans_12    Louisiana_WestBatonRouge_1    Maryland_AnneArundel_19    Maryland_BaltimoreCity_40    Maryland_Baltimore_10    Maryland_Baltimore_3001    Massachusetts_Bristol_1004    Massachusetts_Essex_5    Massachusetts_Hampden_15    Massachusetts_Hampden_16    Massachusetts_Hampden_17    Massachusetts_Hampshire_4002    Massachusetts_Norfolk_8    Massachusetts_Norfolk_9    Massachusetts_Suffolk_1003    Massachusetts_Suffolk_2    Massachusetts_Suffolk_21    Massachusetts_Suffolk_35    Massachusetts_Suffolk_36    Massachusetts_Suffolk_37    Massachusetts_Worcester_20    Michigan_Dickinson_901    Michigan_Dickinson_902    Michigan_Kent_20    Michigan_Midland_940    Michigan_Midland_941    Michigan_Oakland_902    Michigan_Wayne_16    Michigan_Wayne_19    Michigan_Wayne_29    Minnesota_Carlton_6316    Minnesota_Hennepin_50    Minnesota_Hennepin_953    Minnesota_Ramsey_1    Minnesota_Ramsey_3    Minnesota_Ramsey_864    Minnesota_Wright_7    Missouri_Atchison_1    Missouri_Atchison_2    Missouri_Clay_25    Missouri_Clay_5    Missouri_Greene_14    Missouri_Greene_36    Missouri_Jackson_33    Missouri_Platte_23    Missouri_SaintCharles_1002    Missouri_SaintLouis_1    Missouri_SaintLouis_3001    Missouri_SaintLouis_5001    Missouri_SaintLouis_6    Missouri_SaintLouis_7001    Missouri_StLouisCity_72    Missouri_StLouisCity_80    Montana_Missoula_34    Montana_Rosebud_700    Montana_Rosebud_701    Montana_Rosebud_702    Montana_Rosebud_704    Montana_Rosebud_760    Montana_Rosebud_761    Montana_Rosebud_762    Nevada_Clark_1001    Nevada_Clark_16    Nevada_Clark_557    Nevada_Washoe_15    Nevada_Washoe_16    NewHampshire_Hillsborough_16    NewJersey_Bergen_1    NewJersey_Camden_3    NewJersey_Essex_1003    NewJersey_Essex_11    NewJersey_Hudson_6    NewJersey_Morris_3001    NewJersey_Union_4    NewJersey_Union_5001    NewMexico_Bernalillo_15    NewMexico_Bernalillo_23    NewMexico_Catron_1    NewMexico_Eddy_3    NewMexico_SanJuan_14    NewYork_Bronx_74    NewYork_Erie_2    NewYork_Erie_5    NewYork_Essex_5    NewYork_Nassau_5    NewYork_NewYork_10    NewYork_NewYork_56    NewYork_NewYork_63    NorthCarolina_Forsyth_22    NorthCarolina_Forsyth_7    NorthCarolina_Mecklenburg_34    NorthCarolina_Wake_14    NorthDakota_Burke_1    NorthDakota_Dunn_3    NorthDakota_Mercer_1    NorthDakota_Mercer_101    NorthDakota_Mercer_102    NorthDakota_Mercer_103    NorthDakota_Mercer_104    NorthDakota_Oliver_101    NorthDakota_Oliver_2    Ohio_Cuyahoga_2003    Ohio_Cuyahoga_33    Ohio_Cuyahoga_43    Ohio_Franklin_4    Ohio_Hamilton_1013    Ohio_Hamilton_35    Ohio_Hamilton_4002    Ohio_Jefferson_1012    Ohio_Montgomery_29    Ohio_Pickaway_1    Ohio_Pickaway_1001    Ohio_Stark_16    Oklahoma_Cleveland_44    Oklahoma_Cleveland_49    Oklahoma_Kay_600    Oklahoma_Muskogee_167    Oklahoma_Oklahoma_1037    Oklahoma_Oklahoma_33    Oklahoma_Tulsa_127    Oklahoma_Tulsa_174    Oklahoma_Tulsa_191    Oregon_Multnomah_80    Pennsylvania_Allegheny_3    Pennsylvania_Allegheny_31    Pennsylvania_Allegheny_8    Pennsylvania_Beaver_14    Pennsylvania_Berks_9    Pennsylvania_Blair_801    Pennsylvania_Bucks_12    Pennsylvania_Cambria_11    Pennsylvania_Dauphin_401    Pennsylvania_Delaware_2    Pennsylvania_Erie_10    Pennsylvania_Erie_3    Pennsylvania_Lackawanna_2006    Pennsylvania_Lancaster_7    Pennsylvania_Lawrence_15    Pennsylvania_Lehigh_4    Pennsylvania_Luzerne_1101    Pennsylvania_Montgomery_13    Pennsylvania_Northampton_17    Pennsylvania_Perry_301    Pennsylvania_Philadelphia_22    Pennsylvania_Philadelphia_23    Pennsylvania_Philadelphia_29    Pennsylvania_Philadelphia_4    Pennsylvania_Philadelphia_47    Pennsylvania_Washington_200    Pennsylvania_Washington_5    Pennsylvania_York_8    RhodeIsland_Providence_12    RhodeIsland_Providence_19    SouthCarolina_Aiken_3    SouthCarolina_Barnwell_1    SouthCarolina_Lexington_5    SouthCarolina_Richland_1006    Tennessee_Bradley_102    Tennessee_Davidson_10    Tennessee_Davidson_11    Tennessee_Giles_1    Tennessee_Maury_106    Tennessee_McMinn_101    Tennessee_Rutherford_101    Tennessee_Shelby_24    Tennessee_Sullivan_7    Tennessee_Sullivan_9    Tennessee_Williamson_103    Texas_Bexar_36    Texas_Brazoria_1003    Texas_Dallas_44    Texas_Dallas_45    Texas_Dallas_55    Texas_Dallas_69    Texas_ElPaso_27    Texas_ElPaso_37    Texas_Galveston_1002    Texas_Gregg_1    Texas_Harris_1034    Texas_Harris_1035    Texas_Harris_1037    Texas_Harris_24    Texas_Harris_26    Texas_Harris_47    Texas_Harris_7001    Texas_Jefferson_9    Texas_Orange_1001    Texas_Tarrant_1002    Texas_Tarrant_1003    Texas_Travis_17    Utah_Davis_1    Utah_SaltLake_3001    Utah_Utah_2    Utah_Weber_1    Vermont_Chittenden_3    Vermont_Rutland_2    Virginia_AlexandriaCity_9    Virginia_Arlington_20    Virginia_FairfaxCity_5    Virginia_Fairfax_1004    Virginia_Fairfax_18    Virginia_Fairfax_5001    Virginia_Henrico_14    Virginia_NorfolkCity_23    Virginia_RichmondCity_21    Virginia_Roanoke_1004    Virginia_VirginiaBeachCity_7    Washington_King_80    Washington_King_82    WestVirginia_Cabell_6    WestVirginia_Greenbrier_1    WestVirginia_Hancock_1004    WestVirginia_Kanawha_4    WestVirginia_Ohio_7    Wisconsin_Columbia_8    Wisconsin_Kenosha_1001    Wisconsin_Kenosha_16    Wisconsin_Milwaukee_41    Wisconsin_Milwaukee_80    Wisconsin_Rock_1002    Wisconsin_Rock_1004
    ___________    __________________________    _________________    _________________    ________________    ________________    ________________    _____________________    _____________________    _________________    _______________    ______________    _____________________    _______________________    ____________________    __________________    ___________________________    ________________________    ________________________    ___________________________    _____________________    _____________________    _____________________    ___________________    ___________________    ___________________    ___________________    _________________    ____________________    _________________    ____________________    _________________    __________________________    __________________________    __________________________    _________________________    __________________________    __________________________    ________________________    __________________________    __________________________    _______________________    __________________________    __________________________    __________________________    __________________________    __________________________    __________________________    __________________________    __________________________    __________________    ______________________    ________________________    _________________    ___________________    ______________________    ______________________    ______________________    _________________________    _________________________    _________________________    _______________________    ________________________    __________________________    _______________________    __________________________    _______________________    __________________________    _____________________________    ___________________________    _____________________________    __________________________    _____________________________    __________________________    _____________________________    _____________________________    _____________________    ________________________    ________________________    ________________________    ________________________    _____________________    _____________________    _____________________    _________________________    _________________________    __________________________    _____________________________    _____________________________    _____________________________    _____________________________    ________________________    __________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    ____________________________    _________________________    _________________________    __________________________    ______________________    ______________________    ___________________    ___________________    ___________________    __________________________    __________________________    _______________________    ______________________    _______________________    _______________________    _______________________    _______________________    ____________________    ____________________    _______________________    ___________________    ______________________    ___________________    _________________    _________________    ____________________    ____________________    ____________________    ____________________    ____________________    ____________________    ____________________    ____________________    _________________________    _________________________    _________________________    _________________________    _______________________    _______________________    ________________________________________    ________________________________________    ________________    ________________    _________________________    _________________________    _____________________    _______________________    ___________________    ______________________    ______________________    ___________________    ________________    _________________    __________________    __________________    __________________    __________________    __________________    __________________    ________________    ________________    ________________    __________________    __________________    __________________    __________________    ________________    ________________    ________________    ____________________    ______________________    _______________    _______________    ________________    ________________    ___________________    ______________    _________________    _________________    _________________    _________________    _________________    _________________    _________________    _______________    __________________    _______________    _________________    _________________    __________________    _______________________    ________________________    ________________________    _________________    __________________    ________________    ________________    ______________________    __________________    ___________________    _____________________    _______________________    _______________________    ________________    _______________________    __________________________    ________________________    ____________________    __________________________    _______________________    _________________________    _____________________    _______________________    __________________________    _____________________    ________________________    ________________________    ________________________    ____________________________    _______________________    _______________________    __________________________    _______________________    ________________________    ________________________    ________________________    ________________________    __________________________    ______________________    ______________________    ________________    ____________________    ____________________    ____________________    _________________    _________________    _________________    ______________________    _____________________    ______________________    __________________    __________________    ____________________    __________________    ___________________    ___________________    ________________    _______________    __________________    __________________    ___________________    __________________    __________________________    _____________________    ________________________    ________________________    _____________________    ________________________    _______________________    _______________________    ___________________    ___________________    ___________________    ___________________    ___________________    ___________________    ___________________    ___________________    _________________    _______________    ________________    ________________    ________________    ____________________________    __________________    __________________    ____________________    __________________    __________________    _____________________    _________________    ____________________    _______________________    _______________________    __________________    ________________    ____________________    ________________    ______________    ______________    _______________    ________________    __________________    __________________    __________________    ________________________    _______________________    ____________________________    _____________________    ___________________    __________________    ____________________    ______________________    ______________________    ______________________    ______________________    ______________________    ____________________    __________________    ________________    ________________    _______________    __________________    ________________    __________________    ___________________    __________________    _______________    __________________    _____________    _____________________    _____________________    ________________    _____________________    ______________________    ____________________    __________________    __________________    __________________    ___________________    ________________________    _________________________    ________________________    ______________________    ____________________    ______________________    _____________________    _______________________    ________________________    _______________________    ____________________    ___________________    ____________________________    ________________________    ________________________    _____________________    _________________________    __________________________    ___________________________    ______________________    ____________________________    ____________________________    ____________________________    ___________________________    ____________________________    ___________________________    _________________________    ___________________    _________________________    _________________________    _____________________    ________________________    _________________________    ___________________________    _____________________    _____________________    _____________________    _________________    ___________________    ____________________    ________________________    ___________________    ____________________    ____________________    ________________________    ______________    ___________________    _______________    _______________    _______________    _______________    _______________    _______________    ____________________    _____________    _________________    _________________    _________________    _______________    _______________    _______________    _________________    _________________    _________________    __________________    __________________    _______________    ____________    __________________    ___________    ____________    ____________________    _________________    _________________________    _____________________    ______________________    _____________________    ___________________    _____________________    ___________________    _______________________    ________________________    _____________________    ____________________________    __________________    __________________    _____________________    _________________________    _________________________    ______________________    ___________________    ____________________    ______________________    ____________________    ______________________    ______________________    ___________________    ___________________

    01-Jan-1985               NaN                         27                  29                    25                  10                 22                   100                       60                      70                NaN                 80                    53                       100                        80                     60                        50                            80                          80                          120                        60                        NaN                      NaN                     120                    70                      90                     90                   110                  NaN                    NaN                   NaN                    NaN                        190                         230                           230                            180                          140                            210                        NaN                            210                           170                         180                          170                           200                          220                          NaN                           NaN                           NaN                              60                         200                          70                   NaN                         70                      60                     170                      150                       170                     NaN                           70                         NaN                           130                          90                       NaN                             80                          80                        NaN                            90                          110                            130                            NaN                              120                           120                              NaN                              50                           100                               NaN                          110                        120                         150                          70                       NaN                         130                      NaN                      110                       110                           NaN                            80                           30                               50                                 70                               50                            100                        NaN                            NaN                               NaN                             NaN                             NaN                             NaN                             NaN                           NaN                              NaN                              NaN                             NaN                           NaN                               NaN                           NaN                              NaN                             NaN                              NaN                              80                             NaN                              40                           NaN                             NaN                               NaN                             NaN                            60                          90                          NaN                           NaN                      20                       NaN                     70                     80                      NaN                           NaN                           100                        100                      NaN                         NaN                         70                         60                        30                   NaN                       100                       132                       86                     NaN                   160                 106                    NaN                     NaN                    NaN                      NaN                    NaN                     NaN                     NaN                     NaN                         NaN                           84                           66                           88                          80                        160                                 103                                          84                              65                50                        54                         58                           47                        61                     45                      NaN                         72                      65                   52.5                89.7                    97                   91                     63                    93                  NaN                   NaN                    89                  97                114                    86                   NaN                  NaN                   NaN                  87                  81                  NaN                   NaN                       66                    NaN                60                 47                  47                     53                  NaN               NaN                   75                    71                 NaN                    74                  60                   97                  NaN                 96                  NaN                   37                   34                    34                    NaN                         53                          69                       36                   NaN                    56                 115                     65                      49                    55                      83                        98                         68                      25                  39.8                            94                           60                        77                         81                          64                         107                        66                         81                         57                          67                          74                       NaN                         NaN                             NaN                         NaN                        NaN                            71                          99                          87                       NaN                          NaN                           65                          NaN                        37.7                      30.8                  NaN                    NaN                     NaN                      60                   14.8                 81.7                  NaN                   NaN                        66                      NaN                     NaN                     70                   NaN                      NaN                  NaN                    NaN                   65.3                 45                   33                 NaN                   127.9                   52.5                        40                         63                         60                          65                        52                        NaN                        172                         79                     NaN                      37                     40                     31                     37                     39                   36.5                     28                 284.6                 NaN               181.6               NaN                   120                       NaN                        117                    94                    109                    108                   119                     73                    124                     82                      75                         NaN                     23                  NaN                    60                     139                62                 80                27                 113                  125                   NaN                 NaN                         54                        NaN                          65                          NaN                     NaN                     11                      26                       25                        29                        20                        36                        28                    NaN                    NaN                    105                  80                82                   56                    85                   97                    65                    87                 NaN                 NaN                  82                   61                      NaN                   NaN                     NaN                      55.2                     60.5                  67.9                   48.8                    77                  73.2                      NaN                           96                          87                          91                       73                     61                         93                        70                         70                         72                         82                   NaN                           85                            65                          67                       68                          73                          76                             65                            40                        110                             NaN                               110                            100                              90                             88                            56                        77                        75                         NaN                         NaN                         27                         NaN                          39.8                          45                     NaN                      NaN                     64                   NaN                       40                     NaN                         95                      67                    57.5                     NaN                     60                   60                  100                70                   60               NaN                 80                  80                  60                  30                   90                  100                  100                  70                60                100                  50                    60                 30                      80                    90                NaN              NaN                130                 130             110                  49                  NaN                        90                         90                      74.8                     87.1                      69                    90.2                    NaN                      NaN                           80                        53                           67                         70                    90                    56                         31                            70                          68                      55                    34.5                       81                       77                       66                       82                     54.1                   49.3       
    01-Jan-1986               NaN                         20                21.5                    20                10.5               17.5                   100                     51.5                      92                NaN               80.5                  53.5                       105                        80                     60                        50                            80                          80                          130                        60                         80                      NaN                     130                    60                      85                     85                   105                  NaN                    NaN                   NaN                    NaN                        200                         235                           230                            185                          145                            210                        NaN                            195                           175                         180                          175                           190                          215                          NaN                           180                           NaN                              60                         200                          75                   NaN                         65                      70                     175                      145                       165                     NaN                           70                         NaN                           125                          90                       NaN                             65                          70                        NaN                            80                          105                            135                            NaN                              135                           120                               60                              55                            90                               NaN                          110                        120                         150                          70                       NaN                         135                      130                      115                        95                            80                            90                           30                               50                                 70                               50                            100                        NaN                             49                                53                              21                              20                              25                              41                           NaN                              NaN                              NaN                             NaN                           NaN                                34                           NaN                              NaN                             NaN                               29                              75                              40                              35                            30                             NaN                                29                              30                            55                          80                          NaN                           NaN                      20                        70                     75                     80                       50                           NaN                           100                         95                      NaN                         110                         70                         65                        30                   NaN                       100                     132.5                       90                     NaN                 157.5                 106                    NaN                     NaN                    NaN                      NaN                    NaN                     NaN                     NaN                     NaN                         NaN                           84                         68.5                         88.5                          80                        125                                  94                                         103                              65                50                      57.5                         58                           59                        67                     45                       42                       69.5                      65                  62.35               91.85                    92                 66.5                   61.5                    89                  NaN                   NaN                    83                91.5              113.5                    83                    75                  NaN                   NaN                  68                  81                  NaN                   NaN                     70.5                     50                63                 47                  47                   56.5                  130               NaN                   75                  69.5                 NaN                 155.5                  60                   97                   49                 96                  NaN                 36.5                 34.5                  34.5                    NaN                         42                          65                     34.5                 116.8                    51                 115                     60                    48.5                    65                      80                        98                         72                      23                  39.8                            89                         65.5                        81                         81                          65                       108.5                        66                         81                         53                        90.5                        79.5                       NaN                         NaN                              55                         NaN                        NaN                            96                       110.5                          90                       NaN                          NaN                           69                          110                       39.25                      32.9                  NaN                    NaN                     NaN                    49.9                  40.85                 87.3                  NaN                   NaN                        73                      NaN                      53                   70.5                   NaN                      NaN                  NaN                    NaN                  65.55               48.5                 32.5                 NaN                   127.9                   53.3                      42.5                         69                         72                          66                        55                        NaN                      164.5                         80                     NaN                    37.5                     35                     29                     36                   33.5                  31.25                     38                 284.6                 NaN              148.95               NaN                   165                        52                      104.5                  89.5                    110                    104                   118                     65                    112                     82                    69.5                         NaN                     19                   40                    60                     126                67                 97              23.5                 107                131.5                   127                 NaN                         60                         46                          72                          NaN                     NaN                   15.5                      27                     24.5                      33.5                      20.5                      33.5                      25.5                    NaN                     65                     90                77.5                88                 59.5                  87.5                   91                  75.5                  79.5                 NaN                 NaN                75.5                 61.3                      NaN                   NaN                    63.7                     54.65                    61.85                 66.05                   51.2                 79.65                 85.45                      NaN                          138                        87.5                          78                       72                     61                       95.5                      68.5                         71                         72                         71                   NaN                         72.5                            62                          67                     71.5                          76                          76                             65                            41                        110                              40                               110                             95                              90                           85.5                          58.5                      73.5                      73.5                         NaN                        33.4                      24.35                          27                          39.8                        53.5                     NaN                      NaN                   58.5                   NaN                     48.5                     NaN                         93                   69.75                   62.25                     NaN                     60                   65                  105                70                   65                80                 90                  75                  60                  30                   85                   95                  105                  70                60                100                  50                    50                 30                      75                    85                NaN              NaN                130                 110              95                  53                  NaN                      87.5                       87.5                     77.75                    79.35                    73.8                   81.45                    NaN                      NaN                         77.5                        54                         67.5                         75                    90                    63                         30                          68.5                          70                    58.5                      35                       90                       98                     68.5                       81                     49.6                  53.05       

Display sites that are out of compliance. First specify a time range starting in 1987, the first year for which the moving three-year window has three full years of data.

full3years = timerange("1987-01-01","1989-01-01","closed")
full3years = 
	timetable timerange subscript:

		Select timetable rows with times in the closed interval:
		[01-Jan-1987 00:00:00, 01-Jan-1989 00:00:00]

	See Select Times in Timetable.

Next find sites that exceeded the standard during any year in the 1987–1989 time period. The vector exceed is a vector of logical values whose values are 1 (true) where the corresponding variables of moving3yearAvg have values that exceed the standard. You can use logical arrays to index into tables. In this case, index into moving3yearAvg by using exceed to display only the variables for the sites that exceed the standard.

exceed = any(moving3yearAvg{full3years,:}>100,1);
moving3yearAvg(full3years,exceed)
ans=3×85 timetable
     Timestamp     California_Alameda_1001    California_ContraCosta_3001    California_Fresno_5    California_Kern_4    California_LosAngeles_1002    California_LosAngeles_1103    California_LosAngeles_1105    California_LosAngeles_113    California_LosAngeles_1201    California_LosAngeles_1301    California_LosAngeles_16    California_LosAngeles_1601    California_LosAngeles_1701    California_LosAngeles_2    California_LosAngeles_2005    California_LosAngeles_2401    California_LosAngeles_4002    California_LosAngeles_5001    California_LosAngeles_6002    California_LosAngeles_8001    California_Orange_1    California_Orange_1002    California_Orange_5001    California_Riverside_6001    California_Riverside_8001    California_SanBernardino_1    California_SanBernardino_1004    California_SanBernardino_2002    California_SanBernardino_3    California_SanBernardino_9004    California_SanDiego_1    California_SanDiego_1002    California_SanDiego_1004    California_SanDiego_1007    California_SanDiego_3    California_SanDiego_5    California_SanDiego_6    California_SanMateo_1001    California_SantaClara_2004    California_Tulare_2002    Colorado_Adams_3001    Colorado_Arapahoe_1002    Colorado_Arapahoe_3    Colorado_Denver_2    Colorado_ElPaso_4    Delaware_NewCastle_3001    DistrictOfColumbia_DistrictofColumbia_25    Illinois_Cook_3102    Illinois_Cook_40    Illinois_Cook_53    Indiana_Knox_4    Indiana_Lake_1016    Indiana_Marion_70    Kentucky_Boyd_10    Maryland_BaltimoreCity_40    Massachusetts_Hampden_17    Massachusetts_Suffolk_2    Massachusetts_Worcester_20    Missouri_Jackson_33    Missouri_StLouisCity_72    Montana_Missoula_34    Nevada_Clark_1001    Nevada_Clark_16    Nevada_Clark_557    Nevada_Washoe_15    Nevada_Washoe_16    NewHampshire_Hillsborough_16    NewJersey_Bergen_1    NewJersey_Essex_1003    NewJersey_Essex_11    NewJersey_Hudson_6    NewJersey_Union_4    NewYork_Bronx_74    NewYork_Nassau_5    NewYork_NewYork_10    NewYork_NewYork_56    NewYork_NewYork_63    Pennsylvania_Allegheny_31    Pennsylvania_Philadelphia_22    Pennsylvania_Philadelphia_29    Pennsylvania_Philadelphia_47    Texas_Dallas_44    Texas_Harris_1037    Utah_SaltLake_3001    Virginia_Fairfax_5001
    ___________    _______________________    ___________________________    ___________________    _________________    __________________________    __________________________    __________________________    _________________________    __________________________    __________________________    ________________________    __________________________    __________________________    _______________________    __________________________    __________________________    __________________________    __________________________    __________________________    __________________________    ___________________    ______________________    ______________________    _________________________    _________________________    __________________________    _____________________________    _____________________________    __________________________    _____________________________    _____________________    ________________________    ________________________    ________________________    _____________________    _____________________    _____________________    ________________________    __________________________    ______________________    ___________________    ______________________    ___________________    _________________    _________________    _______________________    ________________________________________    __________________    ________________    ________________    ______________    _________________    _________________    ________________    _________________________    ________________________    _______________________    __________________________    ___________________    _______________________    ___________________    _________________    _______________    ________________    ________________    ________________    ____________________________    __________________    ____________________    __________________    __________________    _________________    ________________    ________________    __________________    __________________    __________________    _________________________    ____________________________    ____________________________    ____________________________    _______________    _________________    __________________    _____________________

    01-Jan-1987               100                       133.33                        120                103.33                    196.67                         230                           230                         176.67                          140                            200                        NaN                            190                        173.33                      173.33                       173.33                        196.67                          200                          180                           NaN                           200                      176.67                   143.33                       170                       NaN                        126.67                        103.33                            140                           133.33                           120                              140                          110                     116.67                      146.67                       NaN                      133.33                      135                   116.67                     96.667                        NaN                        93.333                     133                   95.667                     NaN                157.33                 106                      110                              101.33                             NaN                 116                 114                109.5               NaN                189.33                  117                  104.33                        NaN                       108.33                          122                     127.9                   138.67                     NaN                  284.6                 NaN              133.63               140                163.33                      85.5                        107                 113.33                    112                117.67                  108               119.33              108.67               127.67                   126                 NaN                     125.67                          110                            123.33                          96.667                     105               106.67                 120                    81.45        
    01-Jan-1988             102.5                       133.33                        120                   105                       200                         235                           230                          172.5                        142.5                            195                        160                          187.5                        173.33                       177.5                       173.33                         192.5                        197.5                          180                           NaN                           200                         175                      145                     167.5                       NaN                         132.5                          97.5                            145                              130                           120                              135                        112.5                        120                       152.5                       NaN                       132.5                   143.33                      120                        100                        NaN                            95                   131.5                   102.25                     124                149.25                 106                      105                                95.5                             114                 116                 114               98.667               NaN                162.25                112.5                   103.5                        178                       104.75                       112.67                     127.9                      125                     109                  284.6               183.2               141.5               140                163.33                    100.67                     109.75                 119.75                  115.5                123.75                  112                  111               110.5                129.5                   129                 111                        119                          110                               115                            97.5                     105                  105                 120                   82.267        
    01-Jan-1989            103.33                          140                     113.33                   110                    196.67                         230                           NaN                            160                          140                         183.33                        155                         183.33                           175                         170                          170                        196.67                          190                          180                           120                           NaN                      176.67                      160                    166.67                       120                           140                        86.667                         156.67                           126.67                           NaN                           136.67                       116.67                     123.33                      163.33                       170                         130                      150                   126.67                     103.33                        130                        103.33                  133.33                    114.5                   108.5                153.33                 NaN                   83.333                              85.667                            99.5                 121                 180                   83               140                137.67               103.67                  95.667                        178                           93                          102                       NaN                   86.667                      92                    NaN              162.75               136.1               140                   160                    119.33                        112                    121                 122.67                124.33               123.33                   96              106.33               126.33                130.33                 111                     99.667                          NaN                            113.33                             110                     NaN               106.67                 118                    100.9        

The NO2bySite timetable has latitudes and longitudes for the sites, saved as custom properties. The latitudes and longitudes are associated with the variables of the timetable. You can mark the sites that exceeded the standard on a map by using the geoscatter function. The sites that exceeded the standard in 1987 are marked in yellow. (Here, moving3yearAvg{1,:} accesses the first row of the timetable, corresponding to the year 1987.) The sites out of compliance in 1987 were typically large cities such as Los Angeles. Due to the Clean Air Act, a similar analysis using the latest data for the years 2015–2019 would show no sites out of compliance with the NO2 standard.

geoscatter(moving3yearAvg.Properties.CustomProperties.Latitude,...
           moving3yearAvg.Properties.CustomProperties.Longitude,...
           moving3yearAvg{1,:},moving3yearAvg{1,:}>100,'filled')

Figure contains an axes object with type geoaxes. The geoaxes object contains an object of type scatter.

Group by Time Periods

Another way to group by time is by using periodic time units to look for things like seasonality or daily cycles. For example, consider the average daily pattern of NO2 concentrations at each site. It is likely that fossil fuel combustion emissions from human activity and atmospheric photochemistry driven by the sun contribute to a daily cycle in NO2 concentrations. You cannot calculate the mean daily cycle using retime. One approach is to use the varfun function by adding a grouping variable based on the time of day of each timestamp. The timeofday function returns the time of day, or length of time since midnight, as a duration. This code sample shows the approach by using varfun.

NO2bySite.Hour = timeofday(NO2bySite.Timestamp);
NO2bySite.Hour.Format = "hh:mm";
meanDailyCycleNO2 = varfun(@mean,NO2bySite,"GroupingVariable","Hour")

For common calendar periods such as hour of day or month of year, there is a simpler method. These common calendar periods are options of the groupsummary function. Call groupsummary with the "hourofday" option.

meanDailyCycleNO2 = groupsummary(NO2bySite,"Timestamp","hourofday","mean")
meanDailyCycleNO2=24×444 table
    hourofday_Timestamp    GroupCount    mean_Alaska_KenaiPeninsula_1004    mean_Arizona_Apache_10    mean_Arizona_Apache_11    mean_Arizona_Apache_7    mean_Arizona_Apache_8    mean_Arizona_Apache_9    mean_Arizona_Maricopa_3002    mean_Arizona_Maricopa_3003    mean_Arizona_Pima_1011    mean_Arizona_Pima_19    mean_Arizona_Pima_2    mean_Arkansas_Pulaski_1002    mean_California_Alameda_1001    mean_California_Alameda_3    mean_California_Butte_2    mean_California_ContraCosta_1002    mean_California_ContraCosta_2    mean_California_ContraCosta_3    mean_California_ContraCosta_3001    mean_California_ElDorado_9    mean_California_Fresno_241    mean_California_Fresno_242    mean_California_Fresno_5    mean_California_Fresno_6    mean_California_Fresno_7    mean_California_Kern_232    mean_California_Kern_4    mean_California_Kern_5001    mean_California_Kern_6    mean_California_Kern_6001    mean_California_Kern_7    mean_California_LosAngeles_1002    mean_California_LosAngeles_1103    mean_California_LosAngeles_1105    mean_California_LosAngeles_113    mean_California_LosAngeles_1201    mean_California_LosAngeles_1301    mean_California_LosAngeles_16    mean_California_LosAngeles_1601    mean_California_LosAngeles_1701    mean_California_LosAngeles_2    mean_California_LosAngeles_2005    mean_California_LosAngeles_2401    mean_California_LosAngeles_4002    mean_California_LosAngeles_4101    mean_California_LosAngeles_5001    mean_California_LosAngeles_6002    mean_California_LosAngeles_7001    mean_California_LosAngeles_8001    mean_California_Marin_1    mean_California_Mendocino_7    mean_California_Monterey_1002    mean_California_Napa_3    mean_California_Orange_1    mean_California_Orange_1002    mean_California_Orange_5001    mean_California_Plumas_1001    mean_California_Riverside_5001    mean_California_Riverside_6001    mean_California_Riverside_8001    mean_California_Sacramento_1    mean_California_Sacramento_10    mean_California_Sacramento_1001    mean_California_Sacramento_2    mean_California_Sacramento_5002    mean_California_Sacramento_6    mean_California_SanBernardino_1    mean_California_SanBernardino_1004    mean_California_SanBernardino_12    mean_California_SanBernardino_2002    mean_California_SanBernardino_3    mean_California_SanBernardino_4001    mean_California_SanBernardino_6    mean_California_SanBernardino_7002    mean_California_SanBernardino_9004    mean_California_SanDiego_1    mean_California_SanDiego_1002    mean_California_SanDiego_1004    mean_California_SanDiego_1006    mean_California_SanDiego_1007    mean_California_SanDiego_3    mean_California_SanDiego_5    mean_California_SanDiego_6    mean_California_SanFrancisco_4    mean_California_SanFrancisco_5    mean_California_SanJoaquin_1002    mean_California_SanLuisObispo_1004    mean_California_SanLuisObispo_2001    mean_California_SanLuisObispo_2002    mean_California_SanLuisObispo_4001    mean_California_SanMateo_1001    mean_California_SantaBarbara_10    mean_California_SantaBarbara_1010    mean_California_SantaBarbara_1011    mean_California_SantaBarbara_1012    mean_California_SantaBarbara_1013    mean_California_SantaBarbara_1014    mean_California_SantaBarbara_1015    mean_California_SantaBarbara_1016    mean_California_SantaBarbara_1017    mean_California_SantaBarbara_1018    mean_California_SantaBarbara_1019    mean_California_SantaBarbara_1020    mean_California_SantaBarbara_1021    mean_California_SantaBarbara_1025    mean_California_SantaBarbara_1026    mean_California_SantaBarbara_1027    mean_California_SantaBarbara_1030    mean_California_SantaBarbara_2002    mean_California_SantaBarbara_2004    mean_California_SantaBarbara_2005    mean_California_SantaBarbara_4002    mean_California_SantaBarbara_4003    mean_California_SantaBarbara_4004    mean_California_SantaBarbara_5001    mean_California_SantaBarbara_8    mean_California_SantaBarbara_9    mean_California_SantaClara_2004    mean_California_SantaCruz_3    mean_California_Shasta_1001    mean_California_Shasta_6    mean_California_Solano_4    mean_California_Sonoma_3    mean_California_Stanislaus_1003    mean_California_Stanislaus_1004    mean_California_Stanislaus_5    mean_California_Tulare_2002    mean_California_Ventura_1003    mean_California_Ventura_2002    mean_California_Ventura_2003    mean_California_Ventura_3001    mean_California_Ventura_5    mean_California_Ventura_6    mean_California_Ventura_7001    mean_Colorado_Adams_3001    mean_Colorado_Arapahoe_1002    mean_Colorado_Arapahoe_3    mean_Colorado_Denver_2    mean_Colorado_ElPaso_4    mean_Colorado_ElPaso_6001    mean_Colorado_ElPaso_6003    mean_Colorado_ElPaso_6004    mean_Colorado_ElPaso_6005    mean_Colorado_ElPaso_6006    mean_Colorado_ElPaso_6009    mean_Colorado_ElPaso_6011    mean_Colorado_ElPaso_6013    mean_Connecticut_Fairfield_113    mean_Connecticut_Fairfield_123    mean_Connecticut_Hartford_1003    mean_Connecticut_NewHaven_1123    mean_Delaware_NewCastle_2002    mean_Delaware_NewCastle_3001    mean_DistrictOfColumbia_DistrictofColumbia_17    mean_DistrictOfColumbia_DistrictofColumbia_25    mean_Florida_Duval_32    mean_Florida_Duval_70    mean_Florida_Hillsborough_1052    mean_Florida_Hillsborough_1055    mean_Florida_Miami_Dade_27    mean_Florida_Miami_Dade_4002    mean_Florida_Orange_2002    mean_Florida_PalmBeach_1004    mean_Florida_PalmBeach_1101    mean_Florida_Pinellas_18    mean_Georgia_DeKalb_2    mean_Georgia_Fulton_48    mean_Illinois_Cook_1002    mean_Illinois_Cook_1102    mean_Illinois_Cook_1601    mean_Illinois_Cook_3101    mean_Illinois_Cook_3102    mean_Illinois_Cook_3601    mean_Illinois_Cook_37    mean_Illinois_Cook_39    mean_Illinois_Cook_40    mean_Illinois_Cook_4002    mean_Illinois_Cook_4003    mean_Illinois_Cook_4004    mean_Illinois_Cook_4005    mean_Illinois_Cook_45    mean_Illinois_Cook_53    mean_Illinois_Cook_63    mean_Illinois_DuPage_1003    mean_Illinois_SaintClair_10    mean_Indiana_Allen_6    mean_Indiana_Clark_3    mean_Indiana_Jasper_2    mean_Indiana_Jasper_3    mean_Indiana_Jefferson_1    mean_Indiana_Knox_4    mean_Indiana_Lake_1016    mean_Indiana_Marion_30    mean_Indiana_Marion_57    mean_Indiana_Marion_65    mean_Indiana_Marion_70    mean_Indiana_Porter_15    mean_Indiana_Porter_16    mean_Indiana_Posey_1    mean_Indiana_Posey_1002    mean_Indiana_Posey_2    mean_Indiana_Spencer_2    mean_Indiana_Spencer_6    mean_Indiana_Sullivan_1    mean_Indiana_Tippecanoe_1001    mean_Indiana_Vanderburgh_1001    mean_Indiana_Vanderburgh_1002    mean_Indiana_Vigo_1012    mean_Kansas_Wyandotte_1    mean_Kentucky_Boone_7    mean_Kentucky_Boyd_10    mean_Kentucky_Campbell_1001    mean_Kentucky_Daviess_5    mean_Kentucky_Fayette_12    mean_Kentucky_Henderson_13    mean_Kentucky_Jefferson_1020    mean_Kentucky_McCracken_1024    mean_Kentucky_Trigg_1    mean_Louisiana_Calcasieu_100    mean_Louisiana_EastBatonRouge_4    mean_Louisiana_Jefferson_1001    mean_Louisiana_Orleans_12    mean_Louisiana_WestBatonRouge_1    mean_Maryland_AnneArundel_19    mean_Maryland_BaltimoreCity_40    mean_Maryland_Baltimore_10    mean_Maryland_Baltimore_3001    mean_Massachusetts_Bristol_1004    mean_Massachusetts_Essex_5    mean_Massachusetts_Hampden_15    mean_Massachusetts_Hampden_16    mean_Massachusetts_Hampden_17    mean_Massachusetts_Hampshire_4002    mean_Massachusetts_Norfolk_8    mean_Massachusetts_Norfolk_9    mean_Massachusetts_Suffolk_1003    mean_Massachusetts_Suffolk_2    mean_Massachusetts_Suffolk_21    mean_Massachusetts_Suffolk_35    mean_Massachusetts_Suffolk_36    mean_Massachusetts_Suffolk_37    mean_Massachusetts_Worcester_20    mean_Michigan_Dickinson_901    mean_Michigan_Dickinson_902    mean_Michigan_Kent_20    mean_Michigan_Midland_940    mean_Michigan_Midland_941    mean_Michigan_Oakland_902    mean_Michigan_Wayne_16    mean_Michigan_Wayne_19    mean_Michigan_Wayne_29    mean_Minnesota_Carlton_6316    mean_Minnesota_Hennepin_50    mean_Minnesota_Hennepin_953    mean_Minnesota_Ramsey_1    mean_Minnesota_Ramsey_3    mean_Minnesota_Ramsey_864    mean_Minnesota_Wright_7    mean_Missouri_Atchison_1    mean_Missouri_Atchison_2    mean_Missouri_Clay_25    mean_Missouri_Clay_5    mean_Missouri_Greene_14    mean_Missouri_Greene_36    mean_Missouri_Jackson_33    mean_Missouri_Platte_23    mean_Missouri_SaintCharles_1002    mean_Missouri_SaintLouis_1    mean_Missouri_SaintLouis_3001    mean_Missouri_SaintLouis_5001    mean_Missouri_SaintLouis_6    mean_Missouri_SaintLouis_7001    mean_Missouri_StLouisCity_72    mean_Missouri_StLouisCity_80    mean_Montana_Missoula_34    mean_Montana_Rosebud_700    mean_Montana_Rosebud_701    mean_Montana_Rosebud_702    mean_Montana_Rosebud_704    mean_Montana_Rosebud_760    mean_Montana_Rosebud_761    mean_Montana_Rosebud_762    mean_Nevada_Clark_1001    mean_Nevada_Clark_16    mean_Nevada_Clark_557    mean_Nevada_Washoe_15    mean_Nevada_Washoe_16    mean_NewHampshire_Hillsborough_16    mean_NewJersey_Bergen_1    mean_NewJersey_Camden_3    mean_NewJersey_Essex_1003    mean_NewJersey_Essex_11    mean_NewJersey_Hudson_6    mean_NewJersey_Morris_3001    mean_NewJersey_Union_4    mean_NewJersey_Union_5001    mean_NewMexico_Bernalillo_15    mean_NewMexico_Bernalillo_23    mean_NewMexico_Catron_1    mean_NewMexico_Eddy_3    mean_NewMexico_SanJuan_14    mean_NewYork_Bronx_74    mean_NewYork_Erie_2    mean_NewYork_Erie_5    mean_NewYork_Essex_5    mean_NewYork_Nassau_5    mean_NewYork_NewYork_10    mean_NewYork_NewYork_56    mean_NewYork_NewYork_63    mean_NorthCarolina_Forsyth_22    mean_NorthCarolina_Forsyth_7    mean_NorthCarolina_Mecklenburg_34    mean_NorthCarolina_Wake_14    mean_NorthDakota_Burke_1    mean_NorthDakota_Dunn_3    mean_NorthDakota_Mercer_1    mean_NorthDakota_Mercer_101    mean_NorthDakota_Mercer_102    mean_NorthDakota_Mercer_103    mean_NorthDakota_Mercer_104    mean_NorthDakota_Oliver_101    mean_NorthDakota_Oliver_2    mean_Ohio_Cuyahoga_2003    mean_Ohio_Cuyahoga_33    mean_Ohio_Cuyahoga_43    mean_Ohio_Franklin_4    mean_Ohio_Hamilton_1013    mean_Ohio_Hamilton_35    mean_Ohio_Hamilton_4002    mean_Ohio_Jefferson_1012    mean_Ohio_Montgomery_29    mean_Ohio_Pickaway_1    mean_Ohio_Pickaway_1001    mean_Ohio_Stark_16    mean_Oklahoma_Cleveland_44    mean_Oklahoma_Cleveland_49    mean_Oklahoma_Kay_600    mean_Oklahoma_Muskogee_167    mean_Oklahoma_Oklahoma_1037    mean_Oklahoma_Oklahoma_33    mean_Oklahoma_Tulsa_127    mean_Oklahoma_Tulsa_174    mean_Oklahoma_Tulsa_191    mean_Oregon_Multnomah_80    mean_Pennsylvania_Allegheny_3    mean_Pennsylvania_Allegheny_31    mean_Pennsylvania_Allegheny_8    mean_Pennsylvania_Beaver_14    mean_Pennsylvania_Berks_9    mean_Pennsylvania_Blair_801    mean_Pennsylvania_Bucks_12    mean_Pennsylvania_Cambria_11    mean_Pennsylvania_Dauphin_401    mean_Pennsylvania_Delaware_2    mean_Pennsylvania_Erie_10    mean_Pennsylvania_Erie_3    mean_Pennsylvania_Lackawanna_2006    mean_Pennsylvania_Lancaster_7    mean_Pennsylvania_Lawrence_15    mean_Pennsylvania_Lehigh_4    mean_Pennsylvania_Luzerne_1101    mean_Pennsylvania_Montgomery_13    mean_Pennsylvania_Northampton_17    mean_Pennsylvania_Perry_301    mean_Pennsylvania_Philadelphia_22    mean_Pennsylvania_Philadelphia_23    mean_Pennsylvania_Philadelphia_29    mean_Pennsylvania_Philadelphia_4    mean_Pennsylvania_Philadelphia_47    mean_Pennsylvania_Washington_200    mean_Pennsylvania_Washington_5    mean_Pennsylvania_York_8    mean_RhodeIsland_Providence_12    mean_RhodeIsland_Providence_19    mean_SouthCarolina_Aiken_3    mean_SouthCarolina_Barnwell_1    mean_SouthCarolina_Lexington_5    mean_SouthCarolina_Richland_1006    mean_Tennessee_Bradley_102    mean_Tennessee_Davidson_10    mean_Tennessee_Davidson_11    mean_Tennessee_Giles_1    mean_Tennessee_Maury_106    mean_Tennessee_McMinn_101    mean_Tennessee_Rutherford_101    mean_Tennessee_Shelby_24    mean_Tennessee_Sullivan_7    mean_Tennessee_Sullivan_9    mean_Tennessee_Williamson_103    mean_Texas_Bexar_36    mean_Texas_Brazoria_1003    mean_Texas_Dallas_44    mean_Texas_Dallas_45    mean_Texas_Dallas_55    mean_Texas_Dallas_69    mean_Texas_ElPaso_27    mean_Texas_ElPaso_37    mean_Texas_Galveston_1002    mean_Texas_Gregg_1    mean_Texas_Harris_1034    mean_Texas_Harris_1035    mean_Texas_Harris_1037    mean_Texas_Harris_24    mean_Texas_Harris_26    mean_Texas_Harris_47    mean_Texas_Harris_7001    mean_Texas_Jefferson_9    mean_Texas_Orange_1001    mean_Texas_Tarrant_1002    mean_Texas_Tarrant_1003    mean_Texas_Travis_17    mean_Utah_Davis_1    mean_Utah_SaltLake_3001    mean_Utah_Utah_2    mean_Utah_Weber_1    mean_Vermont_Chittenden_3    mean_Vermont_Rutland_2    mean_Virginia_AlexandriaCity_9    mean_Virginia_Arlington_20    mean_Virginia_FairfaxCity_5    mean_Virginia_Fairfax_1004    mean_Virginia_Fairfax_18    mean_Virginia_Fairfax_5001    mean_Virginia_Henrico_14    mean_Virginia_NorfolkCity_23    mean_Virginia_RichmondCity_21    mean_Virginia_Roanoke_1004    mean_Virginia_VirginiaBeachCity_7    mean_Washington_King_80    mean_Washington_King_82    mean_WestVirginia_Cabell_6    mean_WestVirginia_Greenbrier_1    mean_WestVirginia_Hancock_1004    mean_WestVirginia_Kanawha_4    mean_WestVirginia_Ohio_7    mean_Wisconsin_Columbia_8    mean_Wisconsin_Kenosha_1001    mean_Wisconsin_Kenosha_16    mean_Wisconsin_Milwaukee_41    mean_Wisconsin_Milwaukee_80    mean_Wisconsin_Rock_1002    mean_Wisconsin_Rock_1004
    ___________________    __________    _______________________________    ______________________    ______________________    _____________________    _____________________    _____________________    __________________________    __________________________    ______________________    ____________________    ___________________    __________________________    ____________________________    _________________________    _______________________    ________________________________    _____________________________    _____________________________    ________________________________    __________________________    __________________________    __________________________    ________________________    ________________________    ________________________    ________________________    ______________________    _________________________    ______________________    _________________________    ______________________    _______________________________    _______________________________    _______________________________    ______________________________    _______________________________    _______________________________    _____________________________    _______________________________    _______________________________    ____________________________    _______________________________    _______________________________    _______________________________    _______________________________    _______________________________    _______________________________    _______________________________    _______________________________    _______________________    ___________________________    _____________________________    ______________________    ________________________    ___________________________    ___________________________    ___________________________    ______________________________    ______________________________    ______________________________    ____________________________    _____________________________    _______________________________    ____________________________    _______________________________    ____________________________    _______________________________    __________________________________    ________________________________    __________________________________    _______________________________    __________________________________    _______________________________    __________________________________    __________________________________    __________________________    _____________________________    _____________________________    _____________________________    _____________________________    __________________________    __________________________    __________________________    ______________________________    ______________________________    _______________________________    __________________________________    __________________________________    __________________________________    __________________________________    _____________________________    _______________________________    _________________________________    _________________________________    _________________________________    _________________________________    _________________________________    _________________________________    _________________________________    _________________________________    _________________________________    _________________________________    _________________________________    _________________________________    _________________________________    _________________________________    _________________________________    _________________________________    _________________________________    _________________________________    _________________________________    _________________________________    _________________________________    _________________________________    _________________________________    ______________________________    ______________________________    _______________________________    ___________________________    ___________________________    ________________________    ________________________    ________________________    _______________________________    _______________________________    ____________________________    ___________________________    ____________________________    ____________________________    ____________________________    ____________________________    _________________________    _________________________    ____________________________    ________________________    ___________________________    ________________________    ______________________    ______________________    _________________________    _________________________    _________________________    _________________________    _________________________    _________________________    _________________________    _________________________    ______________________________    ______________________________    ______________________________    ______________________________    ____________________________    ____________________________    _____________________________________________    _____________________________________________    _____________________    _____________________    ______________________________    ______________________________    __________________________    ____________________________    ________________________    ___________________________    ___________________________    ________________________    _____________________    ______________________    _______________________    _______________________    _______________________    _______________________    _______________________    _______________________    _____________________    _____________________    _____________________    _______________________    _______________________    _______________________    _______________________    _____________________    _____________________    _____________________    _________________________    ___________________________    ____________________    ____________________    _____________________    _____________________    ________________________    ___________________    ______________________    ______________________    ______________________    ______________________    ______________________    ______________________    ______________________    ____________________    _______________________    ____________________    ______________________    ______________________    _______________________    ____________________________    _____________________________    _____________________________    ______________________    _______________________    _____________________    _____________________    ___________________________    _______________________    ________________________    __________________________    ____________________________    ____________________________    _____________________    ____________________________    _______________________________    _____________________________    _________________________    _______________________________    ____________________________    ______________________________    __________________________    ____________________________    _______________________________    __________________________    _____________________________    _____________________________    _____________________________    _________________________________    ____________________________    ____________________________    _______________________________    ____________________________    _____________________________    _____________________________    _____________________________    _____________________________    _______________________________    ___________________________    ___________________________    _____________________    _________________________    _________________________    _________________________    ______________________    ______________________    ______________________    ___________________________    __________________________    ___________________________    _______________________    _______________________    _________________________    _______________________    ________________________    ________________________    _____________________    ____________________    _______________________    _______________________    ________________________    _______________________    _______________________________    __________________________    _____________________________    _____________________________    __________________________    _____________________________    ____________________________    ____________________________    ________________________    ________________________    ________________________    ________________________    ________________________    ________________________    ________________________    ________________________    ______________________    ____________________    _____________________    _____________________    _____________________    _________________________________    _______________________    _______________________    _________________________    _______________________    _______________________    __________________________    ______________________    _________________________    ____________________________    ____________________________    _______________________    _____________________    _________________________    _____________________    ___________________    ___________________    ____________________    _____________________    _______________________    _______________________    _______________________    _____________________________    ____________________________    _________________________________    __________________________    ________________________    _______________________    _________________________    ___________________________    ___________________________    ___________________________    ___________________________    ___________________________    _________________________    _______________________    _____________________    _____________________    ____________________    _______________________    _____________________    _______________________    ________________________    _______________________    ____________________    _______________________    __________________    __________________________    __________________________    _____________________    __________________________    ___________________________    _________________________    _______________________    _______________________    _______________________    ________________________    _____________________________    ______________________________    _____________________________    ___________________________    _________________________    ___________________________    __________________________    ____________________________    _____________________________    ____________________________    _________________________    ________________________    _________________________________    _____________________________    _____________________________    __________________________    ______________________________    _______________________________    ________________________________    ___________________________    _________________________________    _________________________________    _________________________________    ________________________________    _________________________________    ________________________________    ______________________________    ________________________    ______________________________    ______________________________    __________________________    _____________________________    ______________________________    ________________________________    __________________________    __________________________    __________________________    ______________________    ________________________    _________________________    _____________________________    ________________________    _________________________    _________________________    _____________________________    ___________________    ________________________    ____________________    ____________________    ____________________    ____________________    ____________________    ____________________    _________________________    __________________    ______________________    ______________________    ______________________    ____________________    ____________________    ____________________    ______________________    ______________________    ______________________    _______________________    _______________________    ____________________    _________________    _______________________    ________________    _________________    _________________________    ______________________    ______________________________    __________________________    ___________________________    __________________________    ________________________    __________________________    ________________________    ____________________________    _____________________________    __________________________    _________________________________    _______________________    _______________________    __________________________    ______________________________    ______________________________    ___________________________    ________________________    _________________________    ___________________________    _________________________    ___________________________    ___________________________    ________________________    ________________________

            0                 1826                   11.067                              5                       NaN                      5.5                      NaN                      5.8                      32.726                        14.354                      21.406                   28.032                 24.291                     14.211                         25.197                         23.05                      14.065                          17.794                            21.557                           20.961                             37.392                           12.859                        18.895                        18.505                       30.127                      17.676                       21.78                      26.663                     36.455                     12.487                      13.738                     23.841                      16.139                        51.783                             56.009                             58.113                              40.43                            41.108                             43.376                            35.362                            49.271                             52.205                            45.488                           50.675                             43.835                             41.112                             31.931                             39.447                             39.333                             19.822                             40.603                         19.932                       11.379                          15.293                        18.034                     41.522                       32.273                         38.499                         10.219                           22.653                            36.461                             39.84                           19.016                          25.607                             18.12                            18.808                           20.777                            20.192                           31.541                               43.196                               11.918                               39.857                               45.24                               18.559                              12.178                                27.05                                45.278                            26.012                         28.571                           36.717                           15.058                           37.174                          28.608                        23.827                         26.61                          23.097                            23.121                            26.404                               11.765                                13.988                                18.196                                14.168                             22.684                            23.397                              11.613                               6.8706                                7.521                               6.3204                               5.7838                               8.6386                               8.5229                               11.749                               7.9907                                8.789                               22.127                               7.4138                               7.8793                               7.2338                                8.797                               7.1772                               16.574                               14.849                                11.44                                   10                               5.9286                               7.5291                               10.698                              16.756                            25.186                             30.06                           11.189                             10                        13.729                      21.152                      17.193                            NaN                             17.587                            25.686                         22.386                          12.557                          32.817                          18.426                          16.033                        10.438                         13.6                             24                        32.111                       19.436                        25.254                      34.13                       NaN                     14.745                       19.143                       24.777                       32.953                       8.6858                       21.343                       28.167                       29.845                          26.061                            26.552                            23.204                            28.863                           28.954                          28.074                                  27.881                                           29.858                               18.426                   11.783                         21.97                            18.506                          18.302                         17.395                        14.248                       13.894                          17.03                        18.542                     19.07                    32.172                    25.919                     27.348                     20.137                     29.261                     28.087                      29.35                    28.644                   27.535                    32.97                    32.305                     26.011                     30.004                     26.923                    26.591                   26.643                   26.686                     26.006                        24.952                      15.164                  20.391                   13.09                   11.805                     10.934                   20.888                   30.979                    28.444                    26.321                       NaN                    26.191                    14.774                      15.3                       14                   25.159                        13                   10.077                    11.376                    11.034                        14.754                          11.212                           14.368                        12.105                    21.279                     14.28                   14.613                      23.721                       14.263                      22.191                       24.028                          28.99                          18.132                      6.6434                       13.797                           23.969                            18.506                         25.061                          20.548                            21.404                           32.885                           19.49                         28.777                           16.737                           24.928                         23.542                           27.896                           46.412                               14.3                             21.438                          23.996                           26.006                            31.988                          30.211                           25.601                           26.971                           27.376                            28.731                            12.19                         10.244                      21.988                     12.421                       11.314                       17.478                      27.172                    25.826                    27.888                       8.635                         23.307                        27.626                       22.751                     23.833                      23.184                      13.135                      8.5055                      11.132                    19.503                   14.271                    9.122                     17.107                      29.978                     15.185                         16.403                           24.269                         21.551                           23.377                          19.873                         24.398                           34.543                          24.434                        15.402                      11.642                      11.263                       8.964                      9.7615                      11.129                      10.084                      11.737                     33.768                   39.849                  34.402                   33.333                   28.508                          22.45                          34.946                     28.791                      33.814                      36.543                     33.991                       16.934                      34.889                     27.533                         20.042                          20.522                          NaN                    11.794                     14.667                     35.804                  23.676                 28.538                  7.9273                  34.319                    43.353                     47.154                     18.779                        19.395                           13.542                            22.454                            13.806                       7.7727                     6.5152                      8.3152                        7.0698                         8.8211                         6.8861                         9.4444                         7.8742                        9.2727                      26.154                     30.04                   23.891                   30.198                   20.436                    31.105                    31.069                      22.072                     25.242                    11.988                   12.829                   21.704                    18.443                        14.825                     15.526                      14.913                        15.834                        21.356                      17.654                     14.734                     20.117                      19.899                         30.11                            33.928                           30.068                          24.316                        26.073                        22.344                         29.448                         21.913                          27.444                           28.635                        19.412                       18.415                          25.324                             21.601                           22.857                          23.739                          24.213                            27.479                              24.849                           10.673                            32.308                               15.455                               34.196                                32.07                               37.16                               24.617                             25.375                         25.825                         25.508                            19.818                           9.614                         8.1506                            9.5858                             7.9039                           15.955                        14.828                        14.896                      18.539                     10.455                      15.422                         6.4706                         28.537                      21.874                       19.487                         7.5615                      16.405                    16.805                    25.858                   19.96                   18.08                  27.283                  22.536                  24.406                    15.728                    11.009                  21.249                    26.497                    26.634                   19.892                  16.459                  24.267                   16.319                    15.451                    14.128                    21.076                     22.429                    17.095                20.538                  38.052                  29.908                33.8                   15.523                      14.981                         29.54                          25.977                         23.95                         25.628                       24.213                       26.094                       18.067                        21.325                          25.555                          18.788                           20.008                          18.215                     28.907                       18.878                           8.888                            21.786                          27.369                        19.487                      11.607                        31.082                        28.775                        21.356                         25.235                        15.674                      15.797         
      ⋮

To visualize the daily cycle for the first few sites, use stackedplot. Compare the pattern of a single peak in remote sites in Alaska and Arizona to the morning and evening peaks during rush hour at urban sites in Arizona and California.

meanDailyCycleNO2.GroupCount = [];
meanDailyCycleNO2.hourofday_Timestamp = hours(double(meanDailyCycleNO2.hourofday_Timestamp));
stackedplot(meanDailyCycleNO2,'XVariable','hourofday_Timestamp')

Figure contains an object of type stackedplot.

Grouped Calculations with Functions That Require Multiple Inputs

The retime, groupsummary, and varfun functions all apply functions separately to each table variable. But sometimes you have functions that use more than one table variable as inputs. For example, you might want to find the time or index at which some condition occurred within each group of data values. In such cases, use the rowfun function. It enables you to apply functions that require multiple inputs.

For example, determine when the maximum NO2 concentration occurred at each site. This determination requires a function such as the findMax supporting function referred to in this example. The findMax function requires both timestamps and data values as input arguments. It returns the maximum value with the time at which the maximum value occurred.

To group the data in NO2data by SiteID and find the times when the maximum NO2 concentration occurred at each site, use rowfun. Specify that the inputs to findMax are Timestamp and MeasuredNO2 from NO2data. Convert NO2data to a table so that rowfun returns a table.

NO2data = timetable2table(NO2data);
rowfun(@findMax,NO2data,"GroupingVariable","SiteID","InputVariables",["Timestamp","MeasuredNO2"], ...
    "OutputVariableNames",["MaxMeasuredNO2","MaxOccurrenceTime"])
ans=442×4 table
              SiteID               GroupCount    MaxMeasuredNO2     MaxOccurrenceTime  
    ___________________________    __________    ______________    ____________________

    Alaska_KenaiPeninsula_1004        7071            194          03-Aug-1989 10:00:00
    Arizona_Apache_10                14313             32          01-Jul-1985 09:00:00
    Arizona_Apache_11                13551             33          22-Aug-1985 10:00:00
    Arizona_Apache_7                 13821             25          14-Feb-1985 17:00:00
    Arizona_Apache_8                 13701             14          22-Feb-1989 09:00:00
    Arizona_Apache_9                 13675             25          16-Nov-1988 12:00:00
    Arizona_Maricopa_3002             5746            140          11-Jan-1985 10:00:00
    Arizona_Maricopa_3003             9904            150          08-Mar-1985 17:00:00
    Arizona_Pima_1011                35608            194          22-Jan-1987 10:00:00
    Arizona_Pima_19                  10191             93          22-Nov-1989 10:00:00
    Arizona_Pima_2                   12283            110          27-Jun-1985 09:00:00
    Arkansas_Pulaski_1002            40723             92          27-Jan-1988 05:00:00
    California_Alameda_1001          42863            150          06-Oct-1987 10:00:00
    California_Alameda_3             42453            140          12-Feb-1988 08:00:00
    California_Butte_2               39502            230          31-Jan-1987 19:00:00
    California_ContraCosta_1002      36327             90          12-Mar-1989 15:00:00
      ⋮

With these results you could extend your analysis to find out why the NO2 concentrations were particularly high on those dates.

Supporting Functions

Supporting local functions are defined below.

function [maxVal,maxTime] = findMax(times,vals)
    % Return time at which maximum element of vals occurred
    [maxVal,maxIndex] = max(vals);
    if ~isnan(maxVal)
        maxTime = times(maxIndex);
    else
        maxTime = NaT;
    end
end
function y = findPrctile(x,p)
    % Return data point nearest to percentile p, without interpolation
    xs = sort(x);
    n = sum(~isnan(x)); % use non-NaN elements only
    k = p*n/100 + 0.5;  % index of data point that represents 100*(i-0.5)/n th percentile
    y = xs(round(k));   % data point nearest specified p
end

See Also

| | | | | | | | | | |

Related Topics