menuWorking with AI and R for Excel

Chapter 2: Working with AI and R for Excel

Learning Objectives

  1. Open the Ridgeline workbook and explain what each of its sheets contains and what one row represents.
  2. Explain what an Excel Table is, name a Table, and write formulas with structured references such as =COUNTIFS(Survey[store_id],"S01").
  3. Explain what R, a data frame and an R script are, and how R for Excel turns an Excel Table into a data frame.
  4. Write a data description in R for Excel's 2. Ask your AI box, knowing what the app adds on its own and what only you can supply.
  5. Complete a full round trip: ask an AI for a script, read it, run it, send the results to a new sheet, and check them with Excel formulas.
  6. Read an AI's script critically, recover from an error, and follow the habits that keep AI-assisted analysis honest.

In Chapter 1. Statistics, Data, and AI in Business you met Ridgeline Coffee Co., learned what a data description is, and had your first conversations with an AI about data. Nothing ran, though. The AI talked about methods without touching a single number.

This chapter closes that gap. You'll set up the tools you'll use all semester and go once around the whole loop: Excel, AI, R, and back to Excel. The analysis itself is simple on purpose. Marcus Bell, the co-owner who looks after operations, asks you a reasonable first question:

"We surveyed 600 customers last year. How many of those responses came from each store, and how satisfied were the customers at each one?"

You could answer this with a PivotTable in a couple of minutes, and you'll check your answer with Excel formulas at the end. The point of this chapter is the route, not the destination. Once you can make the round trip with a question this easy, you can make it with every test in the rest of the book.

2.1 The Ridgeline Workbook

Start by downloading the Ridgeline workbook and saving it somewhere you'll find it again, such as a folder for this course. Open it in Excel. If Excel shows a yellow bar that says Protected View or asks you to Enable Editing, click Enable Editing. Files downloaded from the internet open read-only until you do.

The Ridgeline workbook open in Microsoft 365 Excel on Windows, showing the Survey sheet with its blue-banded Table and filter buttons in the header row. The sheet tabs along the bottom read About, Stores, DailySales, Survey, SurveyRaw, Staff, CouponTest. Circle the sheet tabs.

The workbook has seven sheets. The tabs along the bottom are in this order:

Sheet What's on it One row is… Rows
About a short description of the workbook (not data)
Stores the 12 stores a store 12
DailySales each store's sales for every day of 2025 one store on one day 4,380
Survey the customer survey, cleaned a customer's survey response 600
SurveyRaw the same survey before cleaning a survey response (with problems) 603
Staff Ridgeline's employees an employee 104
CouponTest a randomized test of a mobile coupon a loyalty customer in the test 1,000

Click through each tab and look at the first few rows. Notice three things.

First, every data sheet has a single header row of short column names, such as store_id, high_temp_f and would_recommend. The names have no spaces and no units in parentheses. That's deliberate, and you'll see why later in this chapter.

Second, five of the data sheets look different from an ordinary range of cells. They have colored, banded rows and a small drop-down arrow on each header. Those sheets hold Excel Tables, which are the subject of the next section.

Third, SurveyRaw looks plain: no banding and no arrows. It's the survey as it might arrive from a survey tool or a store manager's spreadsheet, with blank cells, inconsistent spellings and a few duplicated rows. It isn't a Table yet. You'll clean it and turn it into one in Chapter 3. Preparing Data in Excel. Until then, leave it alone and use the Survey sheet, which holds the cleaned version.

Keep a clean copy. Before you start experimenting, save a second copy of the workbook (File > Save As, with a name like ridgeline-coffee-original.xlsx). If you ever damage the data by accident, you can start again from the copy instead of downloading it again.

2.2 Excel Tables

Most people's first spreadsheets are just cells with numbers in them. Excel doesn't know that cells A1 through K601 belong together, that row 1 holds column names, or that a new row typed in row 602 is part of the same data. An Excel Table tells it all of that.

Excel Table — A range of cells that Excel manages as one named object, with a header row of column names and one row per record. A Table grows automatically when you add rows or columns, keeps its formatting and formulas consistent, and can be referred to by its name and its column names.

Tables matter in this book for three reasons:

2.2.1 Seeing and naming a Table

Click any cell inside the data on the Survey sheet. A new tab, Table Design, appears at the right end of the ribbon. It only shows up while your cursor is inside a Table, which makes it a quick way to check whether some data is a Table or not.

On the Table Design tab, the box at the far left, labeled Table Name, shows Survey. Every Table in the workbook is named after its sheet: Stores, DailySales, Survey, Staff and CouponTest.

Excel with a cell inside the Survey Table selected and the Table Design tab open on the ribbon. The Table Name box at the far left of the ribbon shows "Survey" and is circled. The Survey data with blue banded rows is visible below.

When you make a Table of your own, Excel gives it a name like Table1. Rename it right away:

  1. Click a cell inside the Table.
  2. Go to Table Design and click in the Table Name box.
  3. Type a short, meaningful name with no spaces, such as SurveyClean, and press Enter.

Table names can't contain spaces and can't look like a cell address (so S01 or Q1 won't work). Names like DailySales or daily_sales are fine. Whatever you choose is also the name R will use, so pick something you'd be happy to type.

To turn an ordinary range into a Table, click any cell in it and choose Insert > Table (or press Ctrl+T). Check that the range Excel proposes covers all of your data and that My table has headers is checked, then click OK. You'll do this for real in the next chapter.

2.2.2 Structured references

Once data is in a Table, you can refer to it by name in any formula. A reference like this is called a structured reference.

Structured reference — A way of referring to a Table, or to one of its columns, by name instead of by cell address. Survey[satisfaction] means "every value in the satisfaction column of the Survey Table," however many rows that is.

The pattern is TableName[column_name]. You don't have to type it all. Click an empty cell on a new sheet (click the + next to the sheet tabs to add one, and rename it Checks by double-clicking its tab). Then type =COUNTA(Su. Excel's AutoComplete list offers Survey. Press Tab to accept it, then type [, and Excel lists the Table's columns. Pick response_id, press Tab, and type ) to finish.

Try these formulas on your Checks sheet. The result you should see is next to each one.

Formula What it asks Result
=COUNTA(Survey[response_id]) How many survey responses are there? 600
=COUNTIFS(Survey[store_id],"S01") How many came from the Downtown store (S01)? 54
=COUNTIFS(Survey[would_recommend],"Yes") How many customers would recommend Ridgeline? 407
=AVERAGE(Survey[satisfaction]) What's the average satisfaction rating? 7.70
=AVERAGEIFS(Survey[satisfaction],Survey[store_id],"S01") What's the average rating at Downtown? 6.83
=SUM(DailySales[revenue]) What was total revenue in 2025? $11,196,559.57
=COUNTIFS(Staff[completed_training],"Yes") How many employees finished barista training? 63

(AVERAGE shows more decimal places than this. Use Home > Decrease Decimal to round the display.)

COUNTA counts the cells in a range that aren't empty. COUNTIFS counts the rows that meet one or more conditions. AVERAGEIFS averages one column, using only the rows where other columns meet your conditions. Its first argument is the column to average, and after that come pairs of "which column to check" and "what it must equal." You can add more pairs. For example, =COUNTIFS(Survey[store_id],"S01",Survey[loyalty_member],"Yes") counts Downtown responses from loyalty members.

Read those formulas aloud and they almost explain themselves: "count the survey rows where store_id is S01." Six months from now, they'll still say what they do.

Excel's text comparisons ignore capital letters. =COUNTIFS(Survey[would_recommend],"yes") gives 407, the same as "Yes". That's convenient in Excel, but R treats "yes" and "Yes" as different values. In the next chapter this difference causes real trouble with the messy survey data, so keep it in mind.

2.2.3 Calculated columns and the current row

Inside a Table, [@column_name] refers to a value in the same row. The @ means "this row." On the DailySales sheet, type rev_check in I1, the first empty cell right of the headers, and the Table grows to include it. In I2, type =[@transactions]*[@avg_ticket] and press Enter. Excel fills the formula down all 4,380 rows at once, making a calculated column. In the first row, 465 transactions × $7.43 = $3,454.95, which matches revenue. Afterward, right-click the rev_check header and choose Delete > Table Columns.

2.2.4 Named ranges, briefly

Excel also lets you give a name to a single cell or a range. On your Checks sheet:

  1. Type S01 in cell B1.
  2. Click B1, then click in the Name Box (the small box to the left of the formula bar that shows B1). Type ChosenStore and press Enter. (You can also use Formulas > Define Name.)
  3. In B2, type =COUNTIFS(Survey[store_id],ChosenStore). In B3, type =AVERAGEIFS(Survey[satisfaction],Survey[store_id],ChosenStore).
  4. Change B1 to S09. Both formulas update, to 47 responses for Pine Ridge.

Named cells are handy for inputs such as a target or a store to look at. For data, use Tables, which grow with the data and name every column.

2.3 R and R for Excel

In this book an AI writes the analysis and R runs it. You won't learn to write R, but you'll need a few words to talk about it.

R — A free programming language and software environment built for statistics and data analysis. Statisticians, scientists and business analysts use it worldwide, and it can run every method in this book.

R works on data arranged the same way as an Excel Table: one row per observation, one column per variable. Its name for that arrangement is a data frame.

Data frame — R's version of a table of data: rows are observations and columns are variables, each column with a name and a single type (numbers, text, dates and so on). When R for Excel reads the Survey Table, R gets a data frame named Survey.

You give R instructions as a short program called a script.

R script — A set of R instructions, written as lines of text, that R carries out from top to bottom. In this book, the AI writes the script, you read it, and R for Excel runs it.

2.3.1 What R for Excel does

R for Excel is an app that runs inside JOLT, an add-in for Excel. It runs real R inside Excel's side panel, so you don't need to install R itself. The app's own description sums up its job: "Run R on your workbook's data. Your AI assistant writes the code, and the results go back into Excel."

It reads the Tables you choose and hands them to R as data frames, builds a prompt for your AI that describes them, runs the script your AI sends back, and puts the results into your workbook.

2.3.2 Installing JOLT and opening the app

Installing an Excel add-in depends on your version of Excel and on whether your school manages your computer, so follow the current instructions at https://jolt.availabooks.com/docs/install.html. The steps there show how to add JOLT to Excel and how to check which versions of Excel it supports. If you're using a computer lab or a school laptop, you may need your IT department to allow the add-in.

Once JOLT is installed, open it from the Excel ribbon and choose R for Excel. The app opens in a panel on the right side of the Excel window, called the task pane.

Excel with the JOLT add-in showing in the ribbon and the R for Excel app opening in the task pane on the right. Circle the JOLT button on the ribbon and the R for Excel entry in JOLT's list of apps.

The first time you open R for Excel, it downloads R into Excel. The status line reads "Starting R… The first time, this downloads about 30 MB." That takes a little while on a slow connection, but only once: after that, R starts from your computer's cache in a few seconds. When it's ready, the status line reads "R 4.x is ready" (with the actual version number).

The R for Excel task pane after R has started, showing the status line "R 4.x is ready" and the four sections from top to bottom: 1. Data (with Add selected data and the Add a table… drop-down), 2. Ask your AI (question box, Copy prompt button, Include 5 sample rows checkbox, Show the prompt), 3. Run R code (code box, Run button, Examples… and Restart R), and the empty Results area.

The task pane has four parts, from top to bottom. You'll use them in this order every time:

2.3.3 From Table to data frame

In 1. Data, open the Add a table… drop-down. It lists every Table in the workbook. Choose Survey.

The 1. Data section of R for Excel after choosing Survey from the Add a table… drop-down. The source shows the name Survey and lists its 11 columns with their detected types: response_id text, visit_date date, store_id text, age number, loyalty_member text, visits_per_week number, order_type text, wait_minutes number, satisfaction number, spend number, would_recommend text.

The Table now appears as a source named Survey, with its columns and the type the app detected for each: number, text or date here. Check these types every time. If a column you expect to be numeric shows up as text, something in it isn't a number, and you'll find out how to fix that in Chapter 3. Preparing Data in Excel.

A few details about how the app hands a Table to R:

You can add more than one Table. A later chapter needs both DailySales and Stores, for example, and you'd add each one. For now, Survey is all you need.

R inside Excel can't reach files or the internet. It sees only the Tables you add in 1. Data. That's a safety feature, and it also means a script that tries to open a file with something like read.csv("survey.csv") will fail. The app tells your AI this in the prompt, but AIs sometimes forget.

2.4 Describing the Data in the "Ask your AI" Box

In Chapter 1. Statistics, Data, and AI in Business you wrote a data description by hand, listing every column with its type and values. R for Excel now does a large part of that for you. It's worth knowing exactly which part.

2.4.1 What the app adds on its own

When you click Copy prompt, the app builds a long prompt and puts it on your clipboard.

Prompt — The text you send to an AI assistant to tell it what you want. In this book a prompt usually includes a data description, a question and a request for an R script.

Click Show the prompt to read it before you send it. It has three parts:

That's a lot of accurate detail that you no longer have to type, and the app can't get it wrong by misremembering a column name.

2.4.2 What only you know

Look again at the "The data" section and ask what an AI still couldn't know from it. The app sees that satisfaction is a number from 4 to 10. It can't tell whether the scale runs from 1 to 10 or 0 to 10, or whether 10 means delighted or furious. It sees that store_id has 12 values. It can't tell that each row is one customer's response, or that S01 through S04 are city stores. And it has no idea what Marcus asked, or that you're in your second week of a statistics course.

So your part of the data description, typed into the 2. Ask your AI box, covers what the column summary can't:

You'll use the same four-line shape in every chapter from now on:

Each row of <data frame> is <one unit>. <What the key columns mean: units, scale direction, coding.>
Question: <the business question in plain words>.
I'm in an intro business statistics course and have learned <methods so far>.
Please <the analysis, if decided>, send the key results to Excel with excel_out(), and explain how to read them.

For Marcus's question, it looks like this:

Each row of Survey is one customer's response to Ridgeline Coffee's 2025 survey. store_id is the store where the customer visited (S01 to S12). satisfaction is the customer's rating of the visit from 1 (very dissatisfied) to 10 (very satisfied).
Question: How many survey responses came from each store, and what is the average satisfaction rating at each store?
I'm in an intro business statistics course and have learned about types of variables, samples, and simple summaries like counts and averages.
Please count the responses and compute the average satisfaction for each store, put both in one table with one row per store, send it to Excel with excel_out(), and explain how to read it.

Notice what it leaves out. It doesn't list all 11 columns, because the app does that. It explains only the two columns the question uses, and it explains their meaning. It also says exactly what shape the answer should take: one table, one row per store. A specific request gets you a script that's easy to check.

Think before you share real data. The prompt contains column summaries, and with Include 5 sample rows checked it contains actual rows. Ridgeline's data is fictional, so share freely in this course. At work, find out what your employer allows before pasting customer or employee data into an AI tool. Leaving the sample rows off is often enough.

2.5 The First Round Trip

Here's the whole loop, step by step.

2.5.1 Step 1: Ask your AI

  1. In 1. Data, make sure Survey is listed. (Add it with Add a table… if it isn't.)
  2. Type the data description above into the 2. Ask your AI box.
  3. Click Copy prompt.
  4. Open your AI assistant in a browser, start a new chat, paste the prompt (Ctrl+V), and send it.

The 2. Ask your AI section of R for Excel with the four-line data description for Marcus's question typed into the question box, the Include 5 sample rows checkbox unchecked, and the Copy prompt button highlighted. A small confirmation that the prompt was copied is visible.

Needs: a reply containing a single fenced R script that uses the Survey data frame directly (no file reading), counts responses by store_id (with table(), aggregate() or tapply()), averages satisfaction by store_id, combines the two into one data frame with one row per store, and calls excel_out() on it with a title. The explanation after the script should say how to read the table (one row per store; the count is the number of responses; the average is on the 1 to 10 scale) and ideally note that stores with fewer responses give less precise averages. The text after this block compares the captured script with the book's example script.

2.5.2 Step 2: Read the script before you run it

Your AI's script will differ in the details from anyone else's. A script for this usually looks like the one below.

# Count the survey responses from each store
counts <- table(Survey$store_id)

# Average satisfaction rating at each store
avg_sat <- aggregate(satisfaction ~ store_id, data = Survey, FUN = mean)

# Put both in one table, one row per store
by_store <- data.frame(
  store_id = avg_sat$store_id,
  responses = as.vector(counts[avg_sat$store_id]),
  avg_satisfaction = round(avg_sat$satisfaction, 2)
)

# Send the table to Excel
excel_out(by_store, "Survey responses and satisfaction by store")

You don't need to know R to follow it. Read it the way you'd read a recipe:

excel_out() isn't part of standard R. R for Excel defines it, and the prompt tells the AI to use it. Each excel_out() call becomes an output card in the Results area: a preview of the result with buttons that put it in your workbook. The title you give it becomes the card's title. A script can call excel_out() several times, once for each result you want.

Now compare this with your AI's script. It may use tapply() instead of aggregate(), or merge() to join two tables, or call excel_out() twice, once for counts and once for averages. Those are all fine. What has to match is the substance: the right data frame, the right columns, the right calculation, and results sent to Excel.

2.5.3 Step 3: Run it

  1. Copy the AI's reply. You can copy the whole reply: when you paste a full AI answer into the code box, the app keeps just the R code and drops the explanation around it.
  2. Click in the 3. Run R code box and paste (Ctrl+V).
  3. Click Run (or press Ctrl+Enter).

The 3. Run R code section with the example script pasted into the code box, and below it the Results area after clicking Run. The Results area shows one output card titled "Survey responses and satisfaction by store" with a preview of the first rows (store_id, responses, avg_satisfaction) and two buttons, New sheet and At selected cell. The Send everything to a new sheet button is visible beneath the card.

The Results area shows what R produced. Anything the script printed appears as text, in the console area at the top of the results.

Console (output) — The text that R prints while a script runs: printed results, messages and warnings. In R for Excel it appears in the Results area, and Console to sheet copies it into the workbook.

Below the console you'll see one output card for each excel_out() call. Our script has one.

2.5.4 Step 4: Send the results to a new sheet

On the output card, click New sheet. The app adds a worksheet to your workbook and writes the table there, starting at the top left. The other button, At selected cell, writes it wherever your cursor is instead, which is handy for building a report sheet. When a script makes several output cards, Send everything to a new sheet writes them all at once.

You should see this:

store_id responses avg_satisfaction
S01 54 6.83
S02 60 7.03
S03 51 7.22
S04 52 6.96
S05 49 7.92
S06 48 7.75
S07 34 8.06
S08 62 7.71
S09 47 8.64
S10 53 8.28
S11 37 8.35
S12 53 8.19

The results are now ordinary cells. You can format them, chart them, sort them or refer to them in formulas. They don't change if the data changes, though. If you fix the data later, run the script again and send the new results to a sheet.

2.5.5 Step 5: Verify in Excel

Before you report anything to Marcus, check it. This is the step that turns "the computer said so" into "I know this is right." Rebuild two of the numbers with formulas that you understand completely, and confirm that they agree.

On the results sheet, click the cell to the right of the first row of results (D2, if the table starts in A1, with headers in row 1). Type:

=COUNTIFS(Survey[store_id],A2)

Press Enter. It should show 54. Instead of typing "S01", the formula uses cell A2, so you can fill it down: double-click the small square at the bottom right of D2 (the fill handle) to copy it down to row 13. Then in E2, type:

=AVERAGEIFS(Survey[satisfaction],Survey[store_id],A2)

and fill it down too. Column D should match the responses column exactly: 54, 60, 51, 52, 49, 48, 34, 62, 47, 53, 37, 53. Column E should match avg_satisfaction once you round it to two decimals.

Two more quick checks catch a different kind of mistake:

The new results sheet created by R for Excel, with the store_id, responses and avg_satisfaction columns in A:C and two verification columns added in D and E using =COUNTIFS(Survey[store_id],A2) and =AVERAGEIFS(Survey[satisfaction],Survey[store_id],A2). The formula bar shows the AVERAGEIFS formula for row 2. A SUM formula below the responses column shows 600.

Here the checks are a little redundant, since COUNTIFS and AVERAGEIFS can answer Marcus's question on their own. In later chapters, R will run tests that Excel can't easily do in one formula. Even then, you'll almost always be able to check something: a group's size, an average, a total. Two tools that agree on the parts you can check give you good reason to trust the parts you can't.

2.5.6 Step 6: Say what it means

A table of numbers isn't an answer yet. Marcus wants to know what it tells him. Looking at the results:

A short reply to Marcus might read:

The 600 survey responses are spread across all 12 stores, from 34 at Westfield to 62 at Cedar Park. Average satisfaction ranges from 6.8 at Downtown to 8.6 at Pine Ridge. All four Metro stores are at the bottom of that range and all four Mountain stores are at the top. A few stores have fewer than 40 responses, so small differences between individual stores shouldn't be over-read. Whether the regional gap is larger than chance would produce is a question I can test properly later.

That last sentence is honest about what you don't know yet. You'll learn to answer it in Chapter 10. Comparing Many Groups: ANOVA.

2.6 When Something Goes Wrong

Sooner or later a script will stop with an error. That's normal, for AI-written code and for code written by experienced programmers. What matters is getting from the error to a working script without guessing.

Suppose the AI's script had this line:

avg_sat <- aggregate(Satisfaction ~ store_id, data = Survey, FUN = mean)

The column is satisfaction, with a lowercase s. R treats Satisfaction and satisfaction as two different names, so it stops and the Results area shows "Error:" followed by R's message, something like object 'Satisfaction' not found.

R's error messages are terse, but they usually say where the trouble is. "Object … not found" almost always means a misspelled name or a column that doesn't exist. Sometimes you can spot the problem yourself. When you can't, use the button the app puts under the error: Copy a prompt to fix it. It copies a prompt that contains your script, the exact error message and the description of your data. Paste that into the same chat where the AI wrote the script, so it can see what it was trying to do.

The Results area of R for Excel after a failed run, showing a red "Error: object 'Satisfaction' not found" message and, beneath it, the Copy a prompt to fix it button, which is circled.

Needs: a reply that identifies the cause (the column is named satisfaction in lowercase, and R names are case-sensitive), returns the complete corrected script in one fenced block rather than just the changed line, and leaves the rest of the analysis unchanged. The text after this block tells the reader to paste the corrected script, click Run again, and re-check the results.

Paste the corrected script into 3. Run R code and click Run again. Then check the results exactly as you would have the first time. A fix can introduce a new mistake.

If the corrected script fails in a new way, repeat the process, one error at a time. If the AI goes in circles, offering the same broken fix twice, start a new chat with a fresh Copy prompt and a more specific question. If results ever seem to come from an earlier script, click Restart R, which starts a fresh R session with nothing left over.

2.7 Reading an AI's Script Critically

An error is the easy kind of problem, because R tells you something is wrong. The dangerous kind is a script that runs perfectly and computes the wrong thing. Here's an example of what that looks like. It isn't from an AI. The book wrote it to make a point:

# Average satisfaction at each store
by_store <- aggregate(wait_minutes ~ store_id, data = Survey, FUN = mean)
excel_out(by_store, "Average satisfaction by store")

It runs. The output card says "Average satisfaction by store." The numbers look plausible, between about 3 and 6. And every one of them is wrong for the question, because the script averages wait_minutes, not satisfaction. The comment and the title describe what the script was supposed to do. Only the code says what it actually does.

You don't need to know R to catch this. You need to ask three questions of every script before you run it.

  1. What data does it use? Find the data frame and column names. Are they the ones your question is about? Does the script filter or drop any rows, for example keeping only one region or removing missing values? If so, is that what you wanted?
  2. What does it calculate? Look for the function names. mean is an average, median a median, sum a total, table a count. In later chapters you'll look for the name of the test, such as t.test or chisq.test, and check it against the test you chose.
  3. Where do the results go? Find each excel_out() call. Does each one send what its title says? Is anything you need missing?

A few warning signs are worth knowing from the start:

When you aren't sure what part of a script does, ask. The AI is good at explaining code, and asking costs nothing.

Needs: a plain-language, line-by-line explanation that notices the mismatch: the comment and title say satisfaction, but the aggregate() line averages wait_minutes by store_id. The reply should say the script does not answer the question and give the corrected line using satisfaction. The text after this block points out that the AI caught the problem because it was asked to compare the code with the question, and that the reader should still check the corrected result with AVERAGEIFS.

Asking an AI to explain a script, and to compare it with your question, is one of the most useful habits you can build. It isn't a replacement for the three questions, though. AIs sometimes explain what code was meant to do rather than what it does, just like the misleading comment above. Read the code yourself, then use the AI to fill in what you don't understand.

2.8 Habits for Working With AI

You'll make this round trip in every chapter. A few habits make it reliable.

Start a new chat for each analysis. Begin it with a fresh Copy prompt, so the AI has a complete, current description of the data. Long chats drift. Details from early on get lost, and an AI can mix up two analyses you discussed an hour apart. Use the same chat for follow-ups to that analysis, such as fixing an error.

Never report a number that didn't come from a run. If you ask an AI "what's the average satisfaction at Downtown?" without running anything, it may answer with a specific-looking number. It hasn't computed anything. It can't see your data, only the summary in the prompt. Numbers you report must come from a script that ran on your data in R for Excel, or from an Excel formula, and you must have checked them.

Read before you run. Ask the three questions about every script: what data, what calculation, what output. It takes a minute, and it catches most problems that don't produce an error.

Verify at least one number in Excel. A count, an average or a total, computed with COUNTIFS, AVERAGEIFS or a built-in function. If the two tools disagree, find out why before you go further.

Keep the script with the results. Paste the script into a cell or a text box near the results sheet, or save it in a notes file with the date. When someone asks "how did you get that?" in three months, you'll have the answer. It also lets you rerun the analysis when the data is updated.

Stay responsible for the conclusion. The AI wrote the code and R did the arithmetic. You chose the question, checked the work and wrote the sentence that goes to Marcus. If it's wrong, "the AI said so" won't help you.

2.9 Summary

The Ridgeline workbook stores each data set as an Excel Table: a named range that Excel manages as one object, grows with the data, and can be referred to with structured references such as =COUNTIFS(Survey[store_id],"S01") and =AVERAGEIFS(Survey[satisfaction],Survey[store_id],"S01"). Named cells are useful for inputs, while Tables are the right home for data. R for Excel, an app in JOLT, turns each Table you add into an R data frame with the same name. It builds a prompt that describes every column, runs the R script your AI writes, and sends results to the workbook through excel_out().

The app describes the columns, but only you know what a row is, what the columns mean, what the business is asking and what you've learned, so that's what goes in the 2. Ask your AI box. The round trip is the same every time: add the Table, describe the data and the question, Copy prompt, get a script, read it, Run, send the output card to a New sheet, verify a number with an Excel formula, and write the answer in plain business language. When a run fails, Copy a prompt to fix it gives the AI everything it needs. When a run succeeds, you still ask what data the script used, what it calculated and where the results went. In your first round trip, you found 600 responses spread unevenly across the 12 stores, with average satisfaction lowest at the Metro stores and highest at the Mountain stores.