menuDescribing Data

Chapter 4: Describing Data

Learning Objectives

  1. Choose summaries and charts that fit a variable's type.
  2. Compute and interpret the mean, median and mode, and explain why they differ when data are skewed or contain outliers.
  3. Compute the range, variance and standard deviation in Excel, and explain step by step what the standard deviation measures.
  4. Use percentiles, quartiles and the interquartile range to describe a distribution and flag outliers with the 1.5 × IQR rule.
  5. Calculate and interpret a z-score.
  6. Describe the shape of a distribution with a histogram, a box plot and the SKEW function.
  7. Summarize data by group with PivotTables, and get the same summaries from R for Excel, checking them against the Data Analysis ToolPak.

4.1 What Does a Typical Day Look Like?

Marcus Bell schedules staff for all 12 Ridgeline stores. He asks you a simple-sounding question: "What does a typical day look like at each store?" He wants to know how many transactions a store usually gets, how much that number moves around from day to day, and what an unusually busy day looks like, so he can staff for normal days without being caught short on the busy ones.

Ridgeline's daily sales data has 4,380 rows, one for each store on each day of 2025. Nobody can look at 4,380 numbers and see a pattern. You need a handful of numbers and a chart or two that capture what matters. This chapter is about choosing those numbers and charts, computing them in Excel, and explaining what they mean. These are descriptive statistics, which you met in Chapter 1. Statistics, Data, and AI in Business: summaries of the data you have.

You'll use two Excel Tables from the Ridgeline workbook: DailySales (one store on one day) and Survey (one customer's response).

4.2 Start With the Variable Type

Before you summarize a column, decide what type of variable it is. The type tells you which summaries make sense.

Variable type Example Useful summaries Useful charts
Nominal order_type, store_id counts, percentages, the most common category bar chart
Ordinal satisfaction (1–10) counts, percentages, median, quartiles (and often the mean) bar chart
Discrete numeric transactions, visits_per_week mean, median, SD, quartiles histogram, box plot
Continuous numeric wait_minutes, spend mean, median, SD, quartiles histogram, box plot

Excel won't stop you from computing something meaningless, such as the sum of customers' ages. The type check is your job.

Every summary in this chapter describes a distribution: the pattern of values a variable takes and how often it takes each one.

Distribution — The pattern of values a variable takes and how often each value (or range of values) occurs.

When you describe a numeric distribution, cover three things: its center (what's typical), its spread (how much values vary), and its shape (whether it's symmetric or lopsided, and whether it has unusual values). The next sections take these one at a time.

4.3 Center: Mean, Median and Mode

4.3.1 The mean

The mean is the ordinary average: add up the values and divide by how many there are.

In words: the mean is the sum of the values divided by the number of values. In symbols, for a sample of n values x₁, x₂, …, xₙ:

x̄ = (x₁ + x₂ + … + xₙ) / n

The symbol x̄ ("x-bar") stands for a sample mean. In Excel:

Mean — The sum of the values divided by the number of values. It's the balance point of the distribution.

Think of the mean as a balance point. If you put each day's value as a weight on a long ruler, the ruler balances at the mean. That's why a single very large value can pull the mean toward it: a heavy weight far out on one end shifts the balance point.

4.3.2 The median

The median is the middle value once the data are sorted. Half the values are at or below it, and half are at or above it. With an even number of values, it's the average of the two middle ones.

Median — The middle value of the sorted data. Half the observations are at or below it and half are at or above it.

The median cares only about order, not about how far out the extreme values are. If Ridgeline's busiest day had 6,780 transactions instead of 678, the median wouldn't change at all. The mean would jump. The median is resistant to extreme values, and the mean is not.

4.3.3 The mode

The mode is the most common value. It's most useful for categorical variables and for discrete numbers with only a few possible values.

Mode — The value (or category) that occurs most often.

For a continuous variable such as spend, the mode is close to useless: almost every value is different, so "most common" depends on accidents of rounding. For a nominal variable such as order_type, it's the only measure of center that makes sense. Counter orders (345 of 600) are the modal order type. There's no such thing as a mean order type.

4.3.4 When the mean and median disagree

Here are the mean and median of visits_per_week, the number of times a week each surveyed customer usually visits:

Measure Formula Result
Mean =AVERAGE(Survey[visits_per_week]) 2.83
Median =MEDIAN(Survey[visits_per_week]) 2
Mode =MODE.SNGL(Survey[visits_per_week]) 1

Why is the mean almost a whole visit higher than the median? Most customers come in once, twice or three times a week, but a few regulars come in every day or more, and the largest value is 14. Those regulars sit far out on the high side and pull the mean up. The median ignores how far out they are.

That's the general rule. When a distribution has a long tail on one side, the mean is pulled toward the tail and the median is not. A long tail to the right (a few very large values) gives mean > median. A long tail to the left gives mean < median. When the mean and median are close, the distribution is roughly balanced, as with survey spend (mean $8.48, median $8.62).

Which should you report? It depends on the question:

"Average" can mislead when data are skewed. Income, house prices, wait times and customer spending are often skewed to the right. Reporting only the mean makes a typical value look larger than it is. When the mean and median differ noticeably, report both and say why.

4.4 Spread: Range, Variance and Standard Deviation

Two stores can have the same average day and still be very different to staff. One might get 400 transactions almost every day. Another might swing between 250 and 550. Measures of spread capture that difference.

4.4.1 The range

The range is the largest value minus the smallest.

Range — The largest value minus the smallest value.

The range is easy to explain, but it depends on only the two most extreme values. One odd day changes it completely. You need a measure of spread that uses every value.

4.4.2 The standard deviation, step by step

The standard deviation (SD) measures how far values typically fall from the mean. It's the most widely used measure of spread, and you'll see it in nearly every chapter from here on, so it's worth building it once by hand.

Use the first five days of 2025 at the Downtown store (S01). These are the first five rows of the DailySales Table.

  1. Add a new worksheet (click + next to the sheet tabs) and name it SD by hand.
  2. In A1 type transactions, and in A2:A6 type the five values: 465, 517, 412, 586, 573.
  3. In D1 type mean, and in D2 enter =AVERAGE(A2:A6). It returns 510.6.
  4. In B1 type deviation, and in B2 enter =A2-$D$2. Fill it down to B6. Each deviation is how far that day was from the mean. The $ signs keep the reference fixed on the mean as you fill.
  5. In C1 type squared, and in C2 enter =B2^2. Fill it down to C6.

Your sheet should look like this:

Day transactions deviation (x − x̄) squared deviation
Jan 1 465 −45.6 2,079.36
Jan 2 517 6.4 40.96
Jan 3 412 −98.6 9,721.96
Jan 4 586 75.4 5,685.16
Jan 5 573 62.4 3,893.76
Sum 0.0 21,421.20

Look at the deviations first. Some are negative (below the mean) and some positive (above it), and they always add to zero. That's what makes the mean the balance point. So you can't measure spread by averaging deviations: the answer would always be zero.

Squaring fixes that. A squared deviation is never negative, so days above and below the mean both count as "spread." Squaring also gives far-away days extra weight: January 3, about 99 transactions below the mean, contributes almost half the total.

  1. In D4 type sum of squares, and in D5 enter =SUM(C2:C6). It returns 21,421.2.
  2. In D7 type variance, and in D8 enter =D5/(COUNT(A2:A6)-1). It returns 21,421.2 / 4 = 5,355.3.
  3. In D10 type SD, and in D11 enter =SQRT(D8). It returns 73.2.

The variance is the average squared deviation, except that for a sample you divide by n − 1 instead of n (more on that in a moment). Its units are squared: "5,355 squared transactions," which means nothing to a manager. Taking the square root brings the units back to transactions. That square root is the standard deviation.

Variance — The average of the squared deviations from the mean (dividing by n − 1 for a sample). Its units are the square of the data's units.

Standard deviation (SD) — The square root of the variance. It measures how far values typically fall from the mean, in the same units as the data.

In words: square each value's distance from the mean, add them up, divide by n − 1, and take the square root. In symbols:

s = √[ Σ(x − x̄)² / (n − 1) ]

In Excel, one function does all of it. In any empty cell, enter =STDEV.S(A2:A6). It returns 73.2, matching your helper columns. =VAR.S(A2:A6) returns the variance, 5,355.3.

So over those five days, Downtown's daily transactions typically sat about 73 away from their mean of 511. Some days were closer (January 2, only 6 away) and some farther (January 3, about 99 away). The SD is a typical distance, not a maximum.

4.4.3 STDEV.S or STDEV.P?

Excel has two standard deviation functions:

For the five Downtown days, =STDEV.P(A2:A6) returns 65.5, smaller than STDEV.S's 73.2. Why divide by n − 1 for a sample? The deviations are measured from the sample mean, and the sample mean is, by construction, the point that's closest to the data. Measured from it, a sample looks a little less spread out than its population really is. Dividing by a slightly smaller number makes up for that. With five values the difference is large. With hundreds of values it barely matters.

When in doubt, use STDEV.S and VAR.S. They're the standard choice for business data, and they match what R's sd() and var() compute. The ToolPak's Descriptive Statistics also uses the sample formulas.

4.4.4 Spread for Ridgeline's stores

Now apply the function to the whole Table:

Across all stores and days, a store-day's transactions typically fell about 89 away from the overall mean of 355. That number mixes two kinds of variation, though: day-to-day swings within a store, and the big differences between busy Metro stores and quiet Mountain stores. You'll separate those later in the chapter with a PivotTable and with R. Downtown on its own has an SD of 63.2, and Aspen Falls only 32.7.

4.5 Percentiles, Quartiles and Outliers

4.5.1 Percentiles

A percentile tells you where a value sits relative to the rest. The 90th percentile of wait time is the wait that 90% of customers' waits are at or below.

Percentile — The value below which a given percentage of the data falls. The 90th percentile has about 90% of the values at or below it.

Service targets are often written this way: "90% of customers served within 8 minutes" is a statement about the 90th percentile.

4.5.2 Quartiles and the interquartile range

The quartiles are three particular percentiles that split the sorted data into four equal parts:

In Excel, QUARTILE.INC takes the data and the quartile number:

Quartile Formula wait_minutes
Minimum =QUARTILE.INC(Survey[wait_minutes],0) 0.5
Q1 =QUARTILE.INC(Survey[wait_minutes],1) 2.8
Median =QUARTILE.INC(Survey[wait_minutes],2) 4.4
Q3 =QUARTILE.INC(Survey[wait_minutes],3) 6.1
Maximum =QUARTILE.INC(Survey[wait_minutes],4) 12.0

These five numbers together are called the five-number summary. =PERCENTILE.INC(Survey[wait_minutes],0.25) gives the same Q1 as QUARTILE.INC(…,1).

Quartile — One of three values that divide sorted data into four parts with equal counts: Q1 (25th percentile), the median (50th) and Q3 (75th).

The interquartile range (IQR) is Q3 − Q1. It's the width of the middle half of the data.

Interquartile range (IQR) — Q3 minus Q1, the range of the middle 50% of the data. Like the median, it isn't affected by extreme values.

The IQR is to the SD what the median is to the mean: a resistant alternative. For skewed data, the median and IQR are often a better pair to report than the mean and SD.

Why ".INC"? Excel has two versions of each function: QUARTILE.INC / PERCENTILE.INC ("inclusive") and QUARTILE.EXC / PERCENTILE.EXC ("exclusive"). They use slightly different rules for values that fall between data points, so they can disagree a little, especially in small data sets. This book uses the .INC versions, which match R's default quantile() method. If two tools give quartiles that differ slightly, a different method is the usual reason.

4.5.3 Flagging outliers with the 1.5 × IQR rule

An outlier is a value that sits unusually far from the rest of the data. Outliers matter in business because they're often the most interesting rows: a data-entry error, a store-day with a broken espresso machine, a customer who waited through a rush. They also distort the mean and SD.

Outlier — An observation that is unusually far from the bulk of the data. A common rule flags values more than 1.5 × IQR below Q1 or above Q3.

The 1.5 × IQR rule draws two "fences":

Any value outside the fences is flagged as a possible outlier. For wait time:

In Excel, put the fences in cells and count what's beyond them:

To see which rows they are, use =FILTER(Survey,Survey[wait_minutes]>G4). Three customers waited longer than 11.05 minutes (11.5, 12 and 12 minutes).

A flag is a reason to look, not a reason to delete. Here the three long waits are believable: a busy Metro store at the morning rush can produce them. They're real customer experiences and stay in the data. If a wait had been recorded as 120 minutes, you'd suspect a typing error and check the source, as you did in Chapter 3. Preparing Data in Excel.

Don't delete outliers to make the data look tidier. Remove a value only if you have evidence it's an error. If you analyze the data both with and without an outlier, report both results.

4.6 z-Scores: How Unusual Is This Day?

Downtown's busiest day of 2025 was December 20, with 632 transactions. Is that remarkable? It's 204 more than Downtown's mean. Whether 204 is a lot depends on how much Downtown normally varies. A z-score answers the question by measuring distance from the mean in standard deviations.

In words: subtract the mean, then divide by the standard deviation. In symbols:

z = (x − x̄) / s

In Excel, first get Downtown's mean and SD. AVERAGEIFS averages only the rows that meet a condition. STDEV.S has no "IFS" version, so wrap the column in FILTER:

(Use cell references instead of typed numbers in your own sheet, so nothing gets rounded along the way.)

December 20 was 3.24 standard deviations above Downtown's average. That's very unusual. Most days at most stores fall within 2 SDs of their mean, and a day more than 3 SDs out is rare. (The next chapter, Chapter 5. Probability and Distributions, makes "rare" precise.) It was the Saturday before Christmas, so it isn't a mystery. For Marcus, the lesson is that the holiday weekend needs to be staffed as its own case, not as a "busy Saturday."

z-score — The number of standard deviations a value lies above (positive) or below (negative) the mean: z = (x − mean) / SD.

z-scores let you compare values on different scales. Aspen Falls averages about 254 transactions with an SD of 32.7. A 320-transaction day there has z = (320 − 253.5) / 32.7 ≈ 2.0, which makes it a more unusual day for Aspen Falls than a 500-transaction day (z ≈ 1.15) is for Downtown, even though 500 is a much bigger number.

4.7 Shape: Histograms, Box Plots and Skewness

4.7.1 Frequency tables and histograms

A frequency table lists each value (or range of values) and how many observations fall there. A histogram draws the frequency table as touching bars: the horizontal axis shows the values, and the height of each bar shows how many observations fall in that range (called a bin).

Frequency table — A table that lists the values or ranges of values of a variable and the number (and often the percentage) of observations in each.

Histogram — A chart of a numeric variable's distribution. The values are divided into bins of equal width, and each bar's height shows how many observations fall in that bin.

Build a frequency table of visits_per_week with the FREQUENCY function:

  1. On a new sheet, in A1 type visits, and in A2 enter =SEQUENCE(15,1,0). It spills the numbers 0 through 14 down column A. These are the bins.
  2. In B1 type customers, and in B2 enter =FREQUENCY(Survey[visits_per_week],A2#). The # refers to the whole spilled range. FREQUENCY counts the values less than or equal to each bin's upper limit (and above the previous one), and spills one extra cell at the end for anything above the last bin.

You'll see 59 customers with 0 visits, 125 with 1, 124 with 2, 90 with 3, and the counts falling steadily after that, down to a single customer at 11 and two at 14.

Charting those counts as touching bars gives a histogram. Excel can also build a histogram directly from the raw data:

  1. Click any cell in the transactions column of the DailySales Table, then press Ctrl+Space to select the column.
  2. Choose Insert > Charts > Insert Statistic Chart > Histogram.
  3. To control the bins, right-click the horizontal axis and choose Format Axis. Under Bins, set Bin width to 25.

Excel histogram of DailySales[transactions] (all 4,380 store-days) created with Insert > Insert Statistic Chart > Histogram, bin width 25. The Format Axis pane is open on the right with Bin width = 25 highlighted. The histogram has a single broad peak in the 300s and a longer tail stretching to the right toward 678.

The histogram of daily transactions has one main hump in the 300s and a tail that stretches further to the right (up toward 678) than to the left (down to 187). That's what the mean of 355 sitting above the median of 345 told you.

Try several bin widths. Too few bins hide the shape. Too many make it look ragged. For 4,380 store-days, bins of 20 to 30 transactions work well.

4.7.2 Box plots

A box plot (or box-and-whisker plot) draws the five-number summary. The box runs from Q1 to Q3, so its length is the IQR. A line inside the box marks the median. The whiskers reach out to the most extreme values that are still inside the 1.5 × IQR fences, and anything beyond them is drawn as a separate dot.

Box plot — A chart of the five-number summary: a box from Q1 to Q3 with a line at the median, whiskers reaching to the most extreme non-outlying values, and outliers drawn as individual points.

Box plots are best for comparing groups side by side. To compare daily transactions across stores:

  1. Select both the store_id and transactions columns of the DailySales Table: click the store_id header cell, then hold Ctrl and click the transactions header cell. (Click the top edge of a header cell so the whole column is selected.)
  2. Choose Insert > Charts > Insert Statistic Chart > Box and Whisker.
  3. Excel draws one box for each store_id. Add a chart title, such as "Daily transactions by store, 2025."

Excel Box and Whisker chart of DailySales transactions by store_id, S01 to S12 left to right. The Metro boxes (S01–S04) sit highest, spanning roughly 350–520; the Mountain boxes (S09–S12) sit lowest, roughly 230–310, and are visibly shorter. Most stores show a few outlier dots above the top whisker (for example S01 near 632) and none below.

The chart shows in one picture what a table of 12 means and 12 SDs would take a while to read. The Metro stores are the busiest and swing the most. The Mountain stores are quieter and steadier. Most stores have a few outlier dots above their top whisker: unusually busy days. No store has unusually low days.

Excel's box plot quartiles. By default, Excel's Box and Whisker chart computes quartiles with the "exclusive" method, so its box edges can differ slightly from QUARTILE.INC. To match the .INC functions, right-click a box, choose Format Data Series, and select Inclusive median under Quartile Calculation.

4.7.3 Skewness

A distribution is symmetric if its left and right sides are near mirror images. It's skewed to the right (positively skewed) if it has a long tail toward large values, and skewed to the left (negatively skewed) if the long tail points toward small values. Skewness is a number that measures this lopsidedness.

Skewness — A measure of a distribution's asymmetry. It is near 0 for a symmetric distribution, positive when the long tail is on the right and negative when it is on the left.

Excel's SKEW function computes it:

Variable Formula Skewness Mean Median Reading
Survey spend =SKEW(Survey[spend]) −0.03 8.48 8.62 essentially symmetric
Daily transactions =SKEW(DailySales[transactions]) 0.49 355.2 345 mildly right-skewed
Visits per week =SKEW(Survey[visits_per_week]) 1.12 2.83 2 clearly right-skewed

A rough guide: skewness between −0.5 and 0.5 is fairly symmetric, between 0.5 and 1 (or −0.5 and −1) is moderately skewed, and beyond 1 (or −1) is strongly skewed. The table also shows the pattern from earlier: the more skewed the variable, the further the mean drifts from the median, always toward the tail.

Shape matters for more than description. Several methods later in the book work best when data are roughly symmetric, or when samples are large enough that skewness stops mattering. You'll learn which in Chapter 6. Sampling and the Central Limit Theorem.

4.8 Summarizing by Group With PivotTables

Marcus asked about each store, not about the chain as a whole. You could write AVERAGEIFS formulas for 12 stores, but a PivotTable does it in a few clicks and lets you rearrange the summary freely.

PivotTable — An Excel tool that summarizes a table by group. You drag fields into Rows, Columns and Values, and choose a summary (sum, count, average and others) for each value.

4.8.1 Average transactions by store

  1. Click any cell in the DailySales Table.
  2. Choose Insert > PivotTable. In the dialog, check that Table/Range shows DailySales, choose New Worksheet, and click OK.
  3. In the PivotTable Fields pane, drag store_id to the Rows area.
  4. Drag transactions to the Values area. Excel shows "Sum of transactions," the total for the year.
  5. Click Sum of transactions in the Values area, choose Value Field Settings…, select Average, and click OK.
  6. With a cell of the averages selected, click Home > Decrease Decimal until one decimal place shows.

Downtown (S01) averages 427.5 transactions a day, Riverside (S03) is the busiest at 473.9, and Aspen Falls (S11) the quietest at 253.5.

  1. To add spread, drag transactions into Values a second time, open its Value Field Settings…, and choose StdDev. (A PivotTable's StdDev uses the sample formula, like STDEV.S. StdDevp is the population version.) Add transactions once more with Max to see each store's busiest day.

A PivotTable on a new sheet with store_id in Rows and three Values fields: Average of transactions, StdDev of transactions and Max of transactions, one decimal place. Rows S01–S12 and a Grand Total. The PivotTable Fields pane is visible on the right showing store_id in Rows and the three value fields in Values.

The SDs reveal something the averages hide. Busier stores also vary more: Riverside's SD is 67.2, while Aspen Falls' is 32.7. Relative to its average, though, each store swings by roughly the same share: every store's SD is between about 13% and 15% of its mean. That's useful for Marcus, because a staffing buffer set as a percentage of a store's normal volume works about equally well at every store.

4.8.2 By day of week and by month

You can reuse the same PivotTable for other groupings.

  1. Drag store_id out of Rows (back to the field list), and drag day_of_week into Rows. Excel usually sorts the days Sun, Mon, … Sat, because it recognizes day names from its built-in custom lists. If yours are alphabetical, click the Row Labels drop-down and choose Sort A to Z, which uses the custom list.
  2. Remove the StdDev and Max fields so only Average of transactions remains.
Day Mon Tue Wed Thu Fri Sat Sun
Average transactions 320.7 329.3 333.7 339.9 365.1 408.2 389.8

Saturday is the busiest day, averaging about 87 more transactions per store than Monday.

  1. Now replace day_of_week with date in Rows. Excel automatically groups the dates into Months (and may add Quarters and Years). If it lists every date instead, right-click any date in the PivotTable, choose Group…, select Months, and click OK.
Month Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
Average transactions 387.8 386.7 378.0 359.9 344.9 321.2 310.8 320.4 337.3 357.7 377.0 382.7

Coffee is a cold-weather business for Ridgeline: the average store-day drops from about 388 transactions in January to about 311 in July. For staffing, Marcus should plan for both a weekly cycle (heavy weekends) and a seasonal one (busy winters).

Drag a second field into Columns. Put store_id in Rows and day_of_week in Columns to see every store's average for every day of the week in one grid. Then choose Insert > PivotChart to chart it.

4.9 Summarizing Categorical Variables

For categorical variables, the summary is a count and a percentage for each category. The satisfaction rating is ordinal with only seven values actually used (4 through 10), so a frequency table is the clearest summary.

  1. On a new sheet, type rating in A1 and enter =SEQUENCE(7,1,4) in A2. It spills 4 through 10.
  2. In B1 type count, and in B2 enter =COUNTIF(Survey[satisfaction],A2#). Because A2# is a spilled range, COUNTIF returns one count per rating.
  3. In C1 type percent, and in C2 enter =B2#/SUM(B2#). Format column C as a percentage (Home > Percent Style).
Rating 4 5 6 7 8 9 10
Customers 5 27 78 158 170 88 74
Percent 0.8% 4.5% 13.0% 26.3% 28.3% 14.7% 12.3%

The mode is 8 and the median is 8. Over a quarter of customers (162 of 600, 27%) gave a 9 or 10, and only 32 (about 5%) gave a 5 or lower. No one rated below 4.

The mean rating is 7.70 (=AVERAGE(Survey[satisfaction])). As Chapter 1. Statistics, Data, and AI in Business pointed out, averaging an ordinal rating treats the gap between each pair of scores as equal. With a 10-point scale that's a common and usually reasonable choice, but the frequency table is the more complete description, and it can't mislead. A chart of these counts is a bar chart (Insert > Insert Column or Bar Chart > Clustered Column), with gaps between the bars because the categories are separate values.

For a nominal variable, COUNTIF works the same way. =COUNTIF(Survey[order_type],"Mobile") returns 136, so 136 / 600 = 22.7% of surveyed customers ordered on the app. For several categories, =UNIQUE(Survey[order_type]) lists them, and a COUNTIF beside that spill counts each. A PivotTable with order_type in Rows and order_type again in Values (it defaults to Count) does the same thing.

4.10 Describe the Data to AI

You now know every statistic Marcus needs, and you've computed them in Excel. In practice, you'll often ask for a full set of summaries by group at once, and R does that in a few lines. This is also a good first test of an AI-written script, because you can check every number it produces against what you computed above.

Open R for Excel and set it up as you did in Chapter 2. Working with AI and R for Excel:

  1. In 1. Data, click Add a table… and choose DailySales. It becomes a data frame called DailySales.
  2. In 2. Ask your AI, type the data description below in the question box.
  3. Click Copy prompt, and paste the prompt into your AI assistant.
Each row of DailySales is one Ridgeline Coffee store on one day of 2025 (12 stores x 365 days = 4,380 rows). transactions is the number of customer transactions that store had that day. store_id identifies the store, S01 to S12 (S01 is Downtown).
Question: What does a typical day look like at each store, and how much do days vary from store to store?
I'm in an intro business statistics course and have learned the mean, median, standard deviation, quartiles and the IQR.
Please compute summary statistics of transactions for each store (number of days, mean, median, standard deviation, Q1, Q3, minimum and maximum), with quartiles that match Excel's QUARTILE.INC. Send the table to Excel with excel_out(), and explain how to read it.

Notice what the description adds to the column summaries the app sends on its own. The app reports that transactions is a number ranging from 187 to 678. It can't know that one row is a store-day, that the question is about each store separately, or that you want quartiles that match Excel.

The R for Excel task pane with DailySales listed under 1. Data (its columns and types shown), and the data description above typed into the 2. Ask your AI question box. The Copy prompt button is highlighted.

Needs: a reply with a base-R script that groups DailySales$transactions by store_id (using tapply, aggregate or a split/sapply), computes n, mean, median, sd, Q1 and Q3 with quantile() (default type 7, ideally noting it matches QUARTILE.INC), min and max, and sends one table to Excel with excel_out(). The explanation should say what each column means and point out that busier stores also vary more. The text after this block checks the script against the walkthrough below.

4.11 Read the Script

Before you run anything, read what the AI sent. A script for this usually looks like the one below.

# The column to summarize and the groups to split it by
x <- DailySales$transactions
g <- DailySales$store_id

# A small function that summarizes one store's days
summarize <- function(v) {
  c(days = length(v), mean = mean(v), median = median(v), sd = sd(v),
    q1 = quantile(v, 0.25, names = FALSE), q3 = quantile(v, 0.75, names = FALSE),
    min = min(v), max = max(v))
}

# Apply it to each store and stack the results into one table
by_store <- do.call(rbind, tapply(x, g, summarize))
by_store <- data.frame(store_id = rownames(by_store), round(by_store, 1))

excel_out(by_store, "Daily transactions by store")

Read it in plain language, top to bottom:

The AI's script may look different, for example using aggregate() instead of tapply(). That's fine, as long as it uses the right data, column, grouping and statistics. Watch for a script that summarizes all stores together instead of each store, or reports the variance where you asked for the SD.

4.12 Run It in R for Excel

  1. Paste the AI's whole reply into the 3. Run R code box. R for Excel keeps just the code.
  2. Click Run (or press Ctrl+Enter).
  3. Under Results, find the output card titled "Daily transactions by store" and click New sheet.

If R reports an error, click Copy a prompt to fix it, paste that prompt into the same AI conversation, and run the corrected code it sends back.

The R for Excel Results area after running the script: an output card titled "Daily transactions by store" with a preview of the first rows (store_id, days, mean, median, sd, q1, q3, min, max) and the New sheet and At selected cell buttons, with New sheet highlighted.

4.13 Interpret and Verify

The new sheet holds a 12-row table. Here are the key columns:

Store Region Mean Median SD Min Max
S01 Downtown Metro 427.5 423 63.2 290 632
S02 University Metro 453.9 446 64.0 308 635
S03 Riverside Metro 473.9 469 67.2 308 678
S04 Old Town Metro 396.4 391 57.8 272 551
S05 Maple Grove Suburban 372.4 369 53.1 266 541
S06 Lakeside Suburban 384.5 377 54.5 268 534
S07 Westfield Suburban 361.3 357 51.0 243 519
S08 Cedar Park Suburban 307.4 304 44.6 218 449
S09 Pine Ridge Mountain 261.1 258 34.6 187 376
S10 Summit Mountain 285.4 280 36.8 192 387
S11 Aspen Falls Mountain 253.5 251 32.7 188 346
S12 Timberline Mountain 285.0 283 37.9 198 420

4.13.1 Two tools, one answer

Check the numbers two ways.

Against your PivotTable. The means and SDs should match the PivotTable you built earlier, store for store. If they don't, check that the script used transactions and not revenue, and that it grouped by store_id.

Against the Data Analysis ToolPak. The ToolPak's Descriptive Statistics tool produces a full set of summaries for one column. If you haven't turned the ToolPak on, choose File > Options > Add-ins, pick Excel Add-ins in the Manage box, click Go…, check Analysis ToolPak, and click OK. (Excel for the web doesn't include the full ToolPak, so use the desktop app.)

The ToolPak needs a plain range of numbers, so first pull out one store's days:

  1. On a new sheet, type S01 in A1. In A2 enter =FILTER(DailySales[transactions],DailySales[store_id]="S01"). It spills Downtown's 365 values into A2:A366.
  2. Choose Data > Data Analysis, pick Descriptive Statistics, and click OK.
  3. Set Input Range to $A$1:$A$366, check Labels in first row, choose Output Range and pick cell C1, check Summary statistics, and click OK.

The Data Analysis ToolPak's Descriptive Statistics dialog with Input Range $A1:1:A$366 (Downtown's FILTERed transactions), Grouped By Columns, Labels in first row checked, Output Range $C$1, and Summary statistics checked. Behind it, column A shows the spilled values under the header S01.

The ToolPak's output lists Mean 427.5, Median 423, Standard Deviation 63.2, Minimum 290 and Maximum 632, matching R's row for S01. It also lists the Sample Variance, Skewness, Range (342), Count (365) and Kurtosis (a shape measure you won't need in this course). Its "Standard Error" isn't a measure of spread in the data. You'll meet it in Chapter 6. Sampling and the Central Limit Theorem.

If R's Q1 or Q3 differ slightly from QUARTILE.INC on the same data, the script used a different quantile method. Ask the AI to use R's default (type 7).

4.13.2 What to tell Marcus

Numbers alone don't answer Marcus's question. Translate them:

A typical day ranges from about 250 transactions at our quietest Mountain stores to about 470 at Riverside. Metro stores are the busiest and also the least predictable: Downtown's days typically swing about 63 transactions either side of its average of 428, while Aspen Falls' swing about 33 either side of 254. Across the chain, Saturdays run about 27% busier than Mondays, and winter months about 25% busier than July. The busiest days, such as Downtown's 632 on the Saturday before Christmas, are more than three standard deviations above normal and should be staffed as special events.

Every number in that paragraph came from a summary you computed and checked. That's the standard for everything you report.

4.14 Summary

Descriptive statistics turn thousands of rows into a few numbers and charts a manager can use. Start with the variable's type: counts and percentages for categorical variables, and center, spread and shape for numeric ones. The mean is the balance point and the median is the middle value. When a distribution is skewed, as visits per week is (mean 2.83, median 2), the mean is pulled toward the long tail and the median is the better description of a typical value. The standard deviation measures how far values typically fall from the mean, and it's built from squared deviations, as you saw step by step. Use STDEV.S for sample data. Quartiles, the IQR and the 1.5 × IQR rule describe spread and flag outliers in a way extreme values can't distort. A z-score measures how unusual a value is in standard deviations, such as Downtown's 632-transaction day at z = 3.24.

Histograms, box plots and SKEW describe shape, and PivotTables summarize by group in a few clicks. For a full set of summaries by group, a short R script does the same job, and you checked its output against a PivotTable and the ToolPak's Descriptive Statistics. In the next chapter, you'll go from describing what happened to measuring how likely it is that something will happen.