Skip to main content
← All weeksInstall R (optional)taco-truck-sales.csv

Week 1 · R & regression unit

Hello, R

What did Luz's truck sell last week?

What you’ll be able to do

Luz runs the Luz’s Tacos food truck. She writes her daily sales in a notebook and wants to know what drives a good day. R is a free calculator-on-steroids that can help her. This week you just learn to talk to it.

Start here: Hello, R

Read Module 1 video transcript
Two students explore a spreadsheet beside the Luz’s Tacos truck.

Words to know

Console:
The box where you type a command and R answers back.
Object:
A labelled container. You put a value in and use the label later.
Vector:
A list of values, like a row of numbers in a notebook.

Follow along

1.Scroll to Your R workspace below, press Start R, type this and press Run. R works like a calculator.

R console
312 + 287
[1] 599

2.Store last week's daily sales in an object called sales. The arrow <- means 'put this into'. c() means 'combine'.

R console
sales <- c(856, 990, 1135, 702, 1180, 1227, 948)
sales
[1]  856  990 1135  702 1180 1227  948

3.Ask R questions about the week.

R console
sum(sales)
mean(sales)
max(sales)
[1] 7038
[1] 1005.429
[1] 1227

Your R workspace

The truck data is already loaded

Results and charts appear here.

Activity checks

Use these object names in your code. Checks run each time you press Run. Unlimited attempts. If you’re logged in, your best result is saved and your class teacher can see it.

  • ⬜ Create tacos with the 7 daily counts
  • ⬜ Store the average in avg_tacos
  • ⬜ Store taco revenue in revenue

Your code is kept in this browser only. Download it to keep a copy.

Activity

Luz's notebook

  1. Create an object called tacos with the number of tacos sold each day: 210, 240, 280, 170, 300, 330, 230.
  2. What was the average number of tacos per day?
  3. If each taco costs $4, use R to work out total taco revenue: sum(tacos) * 4.

Ask the tutor

Paste your R code, an error, or your output and ask anything.

Check your understanding

Week 1 quiz

1. What does `x <- c(3, 5, 7)` do?
2. `mean(c(800, 1000, 1200))` returns:
3. Which is a valid R object name?

Week 1 review

  • R answers commands typed in the Console.
  • <- stores a value in an object; c() combines values into a vector.
  • sum(), mean() and max() summarise a vector.

Coming up: Week 2

Data frames: R's spreadsheet

How do we load a month of sales?

Luz typed 30 days of records into a spreadsheet.