Skip to content

Commit

Permalink
adding a check for no rchunks
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalab committed Oct 25, 2022
1 parent bb34e34 commit 4e80389
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions chapter_to_slides.R
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,14 @@ chapter_to_slides <- function(input,
}

## Check if R chunk is a plot chunk and change if it is
rchunk_inds <- cbind(rchunk_start, rchunk_end)
plot_inds <- which(apply(rchunk_inds, 1, function(ind){
any(str_detect(x[ind[1]:ind[2]], "plot|hist"))
}))
if(length(rchunk_start)){
rchunk_inds <- cbind(rchunk_start, rchunk_end)
plot_inds <- which(apply(rchunk_inds, 1, function(ind){
any(str_detect(x[ind[1]:ind[2]], "plot|hist"))
}))
} else{
plot_inds <- NULL
}

plot_rchunk_start <- rchunk_start[plot_inds]
plot_rchunk_end <- rchunk_end[plot_inds]
Expand Down

0 comments on commit 4e80389

Please sign in to comment.