Comparison length > 1 in `cv_data_slice`.

Open Beginner friendly
#406 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
r
Domain
data

Research direction

The failing check is in cv_data_slice in R/zCV-methods.R at line 26, where class(dlo[[vname]]) == "numeric" returns a length-2 logical when a column is a matrix such as mm. Reproduce by running sim_train_test(N=N, k=k, LOOCV=TRUE) from the Overthinking box in Chapter 7. Done when that call completes without the length-greater-than-one condition error and the per-column type check handles matrix columns.

Written by the indexing model from the issue text.

Description

While working through the 2nd book edition, I went to run R code 7.17 in the Overthinking box n p 210 (Chapter 7). The book code runs as is, but I was interested in computing the LOOCV value to replicate Figure 7.10, so I ran r <- sim_train_test( N=N, k=k, LOOCV=TRUE). I got an error which I traced back to the following line of cv_data_slice:

if (class(dlo[[vname]]) == "numeric") link to source

The call class(dlo[["mm"]]) returns "matrix" "array", so the comparison to "numeric" returns FALSE FALSE, which has length > 1, causing the error. I'm not sure the best way to correct this multiple class type issue, but will work on a PR unless someone beats me to it.

Dominant language
R
Stars
2.4k
Forks
632
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rmcelreath/rethinking

All issues in rmcelreath/rethinking

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.