STAT 1080 - Fall 2026
  • Course Info
    • Overview
    • Syllabus
    • Support
    • Schedule
    • Useful links
  • Weekly Materials
    • W1. Introduction
    • W2. RStudio
    • W3. Correlation
    • W4. Programming
    • W5. Tidyverse
    • W6. Dates/Times and Distributions
    • W7. Data Visualization
    • W8. Statistics & Probability
    • W9. Data & Probability
    • W10. Random Variables
    • W11. Parameters & Estimates
    • W12. Statistical Inference
    • W13. Regression
    • W14. Regression
    • W15. Project Meetings

On this page

  • Part One: Setup
  • Part Two: Decoding the secret message.
  • Part 3: The secret message!
  • Report an issue

R Programming Puzzles

Today you will be creating and manipulating vectors, lists, and data frames to uncover a top secret message.

Some advice: * Work with those around you * Google is your friend! If an error is confusing, copy it into Google and see what other people are saying. If you don’t know how to do something, search for it. * Just because there is no error message doesn’t mean everything went smoothly. Use the console to check each step and make sure you have accomplished what you wanted to accomplish.

Part One: Setup

Each of the following R chunks will cause an error and/or do the desired task incorrectly. Find the mistake, and correct it to complete the intended action.

  1. Create vectors containing the upper case letters, lower case letters, and some punctuation marks.
lower_case <- c("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z")

upper_case <- c("A", "B", "C", "D", "E", "F", "G", "H" "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z")

punctuation <- c(".", ",", "!", "?", "'", """, "(", ")", " ", "-", ";", ":")
Error in parse(text = input): <text>:3:56: unexpected string constant
2: 
3: upper_case <- c("A", "B", "C", "D", "E", "F", "G", "H" "I"
                                                          ^
  1. Make one long vector containing all the symbols.
my_symbols <- cbind(lower_case, upper_case, punctuation)
Error:
! object 'lower_case' not found
  1. Turn the my_symbols vector into a data frame, with the variable name “Symbol”
my_symbols <- dataframe(my_symbols)
Error in `dataframe()`:
! could not find function "dataframe"
names(my_symbols) = Symbol
Error:
! object 'Symbol' not found
  1. Find the total number of symbols we have in our data frame.
len <- length(my_symbols)
Error:
! object 'my_symbols' not found
  1. Create a new variable in your dataframe that assigns a number to each symbol.
my_symbols%Num <- 1:len
Error in parse(text = input): <text>:1:11: unexpected input
1: my_symbols%Num <- 1:len
              ^

Part Two: Decoding the secret message.

This chunk will load up the encoded secret message as a vector:

top_secret <- read.csv("https://raw.githubusercontent.com/kbodwin/decodeR/refs/heads/master/Base_R/Secret_Code")$V1

By altering this top secret set of numbers, you will be able to create a message. Write your own code to complete the steps below.

  1. Add 14 to every number.
  2. Multiply every number by 18, then subtract 257.
  3. Exponentiate every number. (That is, do e1.)
  4. Square every number.

Checkpoint: Headquarters has informed you that at this stage of decoding, there should be 352 numbers in the secret message that are below 17.

  1. Turn your vector of numbers into a matrix with 5 columns.
  2. Separately from your top secret numbers, create a vector of all the even numbers between 1 and 382. Name it “evens”. That is, “evens” should contain 2, 4, 6, 8 …, 382.
  3. Subtract the “evens” vector from the first column of your secret message matrix.
  4. Subtract 100 from all numbers 18-24th rows of the 3rd column.
  5. Multiply all numbers in the 4th and 5th column by 2.
  6. Turn your matrix back into a vector.

Checkpoint: Headquarters has informed you that at this stage of decoding, all numbers in indices 500 and beyond are below 100.

  1. Take the square root of all numbers in indices 38 to 465.
  2. Round all numbers to the nearest whole number.
  3. Replace all instances of the number 39 with 20.

Checkpoint: Headquarters has informed you that your final message should have 344 even numbers.

Part 3: The secret message!

Use your final vector of numbers as indices for my_symbols to discover the final message!
Google the first line of this message, if you do not recognize it, to see what it is.

Paste the message in the Canvas quiz for this assignment, and upload this file (save first!).

Footnotes

  1. number↩︎

© Copyright 2026, Susan Vanderplas

 
  • Report an issue