Asking Claude for help with R

Eleutherodactylus Research Course · Fall 2026

Tom Devitt

2026-10-14

Sign in to your UT Claude

The claude.ai sign-in page, with buttons for Google and Apple and a box for an email address

  1. Go to claude.ai
  2. Type EID@eid.utexas.edu in the email box, using your own EID in lowercase. Don’t click Google or Apple.
  3. Click Continue with email, then sign in with your UT login and Duo.
  4. Click your name at the bottom left and choose UT Austin Campus.

It’s free for UT students and separate from any personal Claude account.

Same error, two prompts

Error in seq.default(...) : wrong sign in 'by' argument

✗ Weak prompt

my R code gives this error, fix it

Claude has to guess. A likely guess is that your start and end times are swapped, and it may rewrite your chunk.

Your times aren’t swapped, so you lose 20 minutes checking them.

✓ Better prompt

I'm rendering a Quarto notebook in RStudio (R 4.5.3, seewave, tuneR).
This chunk fails at Step 4:
  dom_freq_khz <- function(piece) {
    spec <- meanspec(piece, wl = 512, plot = FALSE)
    ...
  }

Error: seq.default: wrong sign in 'by' argument
It works for most calls but fails for some. My shortest calls are
about 10 ms long at 44.1 kHz.
I'm learning R, so teach me how to debug this rather than handing
me the fix. Explain what the error means, then give me a hint or a
question that points me to the cause. Let me try a fix myself, and
check my reasoning before you show me yours.

Claude’s hint: count the samples

Claude asks: How many samples are in a 10 ms call at 44.1 kHz? To answer, you need two terms.

Sampling rate. A recorder doesn’t store a smooth wave. It measures the sound pressure over and over, and each measurement is a sample. At 44.1 kHz it takes 44,100 samples every second.

A 10 ms call lasts 0.010 s, so it holds 0.010 × 44,100 = 441 samples.

Window length (wl). To find a call’s frequencies, meanspec() cuts the sound into chunks called windows, analyzes each one, and averages them. wl = 512 makes every window 512 samples long, which is 11.6 ms at 44.1 kHz.

Call: 441 samples Window: 512 samples

The window is longer than the call, so it can’t fit even once. meanspec() then asks seq() to count from a start point to an end point that comes before it, and seq() throws the error.

Shrinking the window

The window has to fit inside the call. Use the largest power of 2 (128, 256, 512, …) that fits, because the math inside meanspec() runs fastest on those sizes.

wl <- min(512, 2^floor(log2(length(piece@left))))

Read it from the inside out, for a 441-sample call:

  • length(piece@left) is 441, the number of samples in the call (@left is the recording’s left channel)
  • log2(441) is 8.78, because 28.78 = 441
  • floor(8.78) rounds down to 8, so the window will fit
  • 2^8 is 256, a window shorter than the call
  • min(512, 256) is 256. Long calls still get 512; only short ones get a smaller window

The cost: a smaller window gives coarser frequencies. Each step in the spectrum is the sampling rate divided by wl, so 44,100 / 512 ≈ 86 Hz but 44,100 / 256 ≈ 172 Hz. Check that’s precise enough for what you measure.

Every time you ask Claude

  • Paste the exact error, the chunk that failed, and your setup
  • Say what works and what doesn’t
  • Ask it to teach you: a hint first, then check your fix
  • Ask what any term you don’t know means, the way we did with sampling rate and window length
  • Look up unfamiliar arguments with ?function before you trust them
  • Don’t paste undescribed species’ names or localities, or pod recordings. Made-up values debug just as well

Prepared with Claude Code (Claude Opus 5.5, Anthropic): slides and first draft.