News for hackers. Stuff that matters.
Re:R: Introduction to Data Science by nutshell42 on Saturday March 02, 2024 @05:12PM (#39576225)
> Functions like sapply vs mapply are tricky to reason about from the documentation alone.

Could you please expand on that? It's unclear what you're referring to.

> The values NA vs Null vs integer(0) are all used as standins for real thrown errors and knowing which one to check for after calling a function can be tough.

`checkmate::assert_numeric()` (or similar)

with base R you want isTRUE():

`stopifnot(isTRUE(is.finite(x)))` (or is.na or anything else) will error on empty values.

Re:R: Introduction to Data Science by acc_297 on Sunday March 03, 2024 @09:34AM (#39581052)
I’ll check out those assert functions and I only meant that having apply,lapply,sapply,mapply took some getting used to most programming languages I had used prior include only 1 map / apply function and it’s still not clicking for me when there are performance penalties choosing one over another although I’ve read in the documentation that there are pros and cons