@gaborcsardi@fosstodon.org
@gaborcsardi@fosstodon.org avatar

gaborcsardi

@gaborcsardi@fosstodon.org

Software Engineer at Posit PBC

This profile is from a federated server and may be incomplete. Browse more on the original instance.

coolbutuseless, to random
@coolbutuseless@fosstodon.org avatar

hypothetical: what would happen if I

  • manually allocated some memory in C (with malloc)
  • Crafted the memory to be an R object by writing a proper SEXP header for it
  • Returned this to R

Would R consider this cuckoo object to be real? It wouldn't appear in the list of objects to be garbage collected - would that impact its validity?

gaborcsardi,
@gaborcsardi@fosstodon.org avatar

@coolbutuseless My guess is that this will crash eventually.

But FWIW there is an "official" way to use your own allocator, with the Rf_allocVector3() function.

gaborcsardi,
@gaborcsardi@fosstodon.org avatar

@coolbutuseless Not necessarily crash, but potentially undefined behavior. E.g. if you put your object into a VECSXP or ENVSXP that is allocated by R, and/or put objects allocated by R into your VECSXP,/ENVSXP/etc. that'll probably confuse the GC.

More of a feeling than certainty...

eamon, to random
@eamon@social.coop avatar

I tried opening an RStudio project from 2017 for which I used {packrat}, and I was disappointed—but not surprised—that it didn't work. I'm becoming convinced that "reproducible analyses" are a pipe dream.

gaborcsardi,
@gaborcsardi@fosstodon.org avatar

@eamon Well, to make it reproducible, you'd need to use the same system as back then.

Or, you can try "reproducibility by hindsight" with the https://github.com/r-hub/evercran#readme project. But in your case you probably still need to set some compiler options, e.g. to use C++-11 by default.

gaborcsardi, to random
@gaborcsardi@fosstodon.org avatar

GitHub Actions now supports free arm64 macOS runners for open source projects!
I have just updated https://github.com/r-lib/actions to support the new macos-14 runner. Add this runner to your test matrix if you want to test your R package on arm64 macOS 14.


https://github.blog/changelog/2024-01-30-github-actions-introducing-the-new-m1-macos-runner-available-to-open-source/

jameslairdsmith, to random

friends, I have a question: given that I have some built R package on disk, what is the blessed/easiest way can I (programmatically) check if it's in source or binary format? Beyond just checking the file extension.

gaborcsardi,
@gaborcsardi@fosstodon.org avatar

@jameslairdsmith Check if they have a /Meta directory, if yes they are binary, otherwise source.
If you also want the R version, build date, etc. then parse the DESCRIPTION file in the package, and see if it has a Built field. E.g. first is source, second is binary:

❯ desc::desc_get(file = "callr_3.7.3.9000.tar.gz", "Built")
Built
NA

❯ desc::desc_get(file = "callr_3.7.3.9000.tgz", "Built")
Built
"R 4.2.3; ; 2023-03-27 21:34:25 UTC; unix"

davidhodge931, to random

Hot take: I find the . prefix in arguments a bit annoying, as it's hard to remember whether a function is using it or not. E.g. dplyr::filter does, but tidyr::pivot_longer does not. The dot also means you have to type an extra character. I assume the benefits of it outweigh these things??

gaborcsardi, (edited )
@gaborcsardi@fosstodon.org avatar

@davidhodge931 The rule is that if the function takes "data" in ... argument names, then optional arguments have a dot prefix, so they are not mistaken for ... arguments.

The most common example is that the user passes column names as argument names, and when the function passes on named arguments to another function.

(And yes, because of this, it is a bad idea to have column names starting with a dot.)

gaborcsardi,
@gaborcsardi@fosstodon.org avatar

@davidhodge931 You do use ... often, e.g. in
dplyr::filter(mtcars, cyl >= 6)
cyl > 6 does into ....

But it is actually true that there are some functions that wouldn't need the dot prefixed arguments, and there are also some functions that should probably use them and they don't.

Nevertheless, tab-completion helps.

coolbutuseless, to random
@coolbutuseless@fosstodon.org avatar

It annoys me when R packages are hosted on rforge.

gaborcsardi,
@gaborcsardi@fosstodon.org avatar
gaborcsardi, to random
@gaborcsardi@fosstodon.org avatar

This is how httr2 and other packages use the base |> pipe in examples, and still support older R, including a clean R CMD check:
https://github.com/tidyverse/purrr/commit/426acdd50424b8cd6029d237c4d4e81d94ec42a6#diff-611496f412cac947be720d17a0ee6d7463221d14731fbc18244756271e8f5189

Ie. you need a configure (+ configure.win) file that creates an Rd macro on older R, that rewrites the examples with |>.
You'll also need Biarch: true in DESCRIPTION.

Clean R CMD check from R 3.6.x to R-4.4.x: https://github.com/r-lib/httr2/actions/runs/7548766508

gaborcsardi,
@gaborcsardi@fosstodon.org avatar

@sckottie AFAICT the base pipe is completely supported in package code. (Not that much support is needed from the tidyverse.)

But if you meant when the tidyverse packages will use the base pipe in their code, the earliest for that is after R 4.5.0, because they support the previous 4 R releases.

But actually few tidyverse packages use the pipe in their code, apart from in the documentation, which is already updated or in the process of updating.

gaborcsardi,
@gaborcsardi@fosstodon.org avatar

@jonthegeek @sckottie Yes, I expect that (the little) %>% usage in packages will move to |>.

The major problem with %>% is not speed, though. (Unless you use it in tight loops.) It is that it is harder to debug.

gaborcsardi,
@gaborcsardi@fosstodon.org avatar

@klmr Yeah, it is trickier for package code. Rd having run-time macros means that we don't need to change the manual files.

Unfortunately there is no nice workflow currently for transpiling package code before installation.

jonthegeek, to datascience
@jonthegeek@fosstodon.org avatar

🎂It's my birthday!🎂
To celebrate, I'm... Working to build a friendly, diverse community at https://r4ds.io, just like I do every day! It'd make my day if you supported our efforts at https://r4ds.io/donate !

gaborcsardi,
@gaborcsardi@fosstodon.org avatar

@jonthegeek Happy birthday!

coolbutuseless, to random
@coolbutuseless@fosstodon.org avatar

Adventures in CRAN: Another CRAN rejection for {yyjsonr}.

CRAN is now reporting a clang-ASAN issue that I cannot reproduce with my clang-ASAN setup (using {rhub2})

Now what am I supposed to do?

Note: I have some line numbers related to the error, so I can do some digging.

But I can't do any testing to see if it's fixed. I have to use CRAN submission as my test runner.

Not something I want. And pretty sure they don't want it either.

gaborcsardi,
@gaborcsardi@fosstodon.org avatar

@coolbutuseless Where do you see that? At https://cran.rstudio.com/web/checks/check_results_yyjsonr.html (I think) there is only one strlen-related issue.

gaborcsardi,
@gaborcsardi@fosstodon.org avatar

@coolbutuseless @_TimTaylor I can repro this. Add (temporarily, not for the submission)

PKG_CFLAGS+=-fsanitize=pointer-overflow -fsanitize-trap=pointer-overflow

to src/Makevars, and then run the tests in a debugger:

R -d lldb
run
testthat::test_local()

gaborcsardi,
@gaborcsardi@fosstodon.org avatar

@coolbutuseless @_TimTaylor
According to the docs at https://www.stats.ox.ac.uk/pub/bdr/memtests/README.txt
CRAN does not use these flags, but it seems like they do. :(

gaborcsardi,
@gaborcsardi@fosstodon.org avatar

@coolbutuseless @_TimTaylor I meant that you can do the Makevars change and test on your macOS, no need for a sanitizer build.

gaborcsardi,
@gaborcsardi@fosstodon.org avatar
gaborcsardi,
@gaborcsardi@fosstodon.org avatar

@coolbutuseless Is it possible that you introduced the second bug while fixing the first one? Or they are completely unrelated?

Nevertheless, I agree that it is hard to be sure about the configs, unfortunately.

gaborcsardi,
@gaborcsardi@fosstodon.org avatar

@coolbutuseless Yeah, that machine is hard to fully replicate. Some things you can replicate by setting flags on a mac, and/or with a recent clag, but others need a dev xcode or a dev macos.

lwpembleton, to random
@lwpembleton@genomic.social avatar

Need to add non-CRAN packages as a dependency to your package?

Add the ‘Remotes’ section to your description so that it is downloaded and installed before your package.

More info here 👇
🔗https://cran.r-project.org/web/packages/devtools/vignettes/dependencies.html

gaborcsardi,
@gaborcsardi@fosstodon.org avatar

@jangorecki @lwpembleton How can install.packages() resolve dependencies in Additional_dependencies? It doesn't resolve them by default for me, is there an option to turn this behavior on?

gaborcsardi,
@gaborcsardi@fosstodon.org avatar

@jangorecki @lwpembleton Which basically means that Additional_repositories actually does nothing at all, install.packages() does not use that field. You need to specify the repo manually, nothing is automatic.

It also does not seems like the preferred way:
https://github.com/search?q=%22Remotes%3A%22+path%3A**%2FDESCRIPTION&type=code
https://github.com/search?q=%22Additional_repositories%3A%22+path%3A**%2FDESCRIPTION&type=code

coolbutuseless, to random
@coolbutuseless@fosstodon.org avatar

Adventures in CRAN (upcoming weekend "fun")

  • Can I figure out how to run Docker on my ARM Mac.
  • Does clang-ASAM run under docker on an ARM Mac?
  • Can Ifigure out how to build {yyjsonr} under clang-ASAN under Docker on ARM Mac
  • Can I debug a memory issue related to strlen() when running tests in {yyjsonr} under clang-ASAN under Docker on ARM Mac.

gaborcsardi,
@gaborcsardi@fosstodon.org avatar

@coolbutuseless Let me know if you run into issues.

coolbutuseless, to random
@coolbutuseless@fosstodon.org avatar

Adventures with CRAN.

Adding tests and vignettes just seems to increase the exposed surface area for CRAN checks.

If I want a better chance of getting my pkg on CRAN, I should just never add tests?

gaborcsardi,
@gaborcsardi@fosstodon.org avatar

@coolbutuseless You can also try to run https://github.com/r-hub/rhub2, that should be faster and it uses GitHub Actions, so it is (somewhat) easier to debug.

neilstats, to random

Some problems that are causing me much 😒 today:

Using {qs}, why does qsave() produce different files (for some objects) on Linux vs. Windows?

Using {targets}, why do dynamic branches get given different names on Linux vs. Windows?

gaborcsardi,
@gaborcsardi@fosstodon.org avatar

@neilstats But for the record, this is the native encoding difference:

❯ R -q -e 'saveRDS(1:10, "out1.rds")'
❯ LANG=C R -q -e 'saveRDS(1:10, "out2.rds")'
❯ md5sum out1.rds out2.rds
12d3b8f08ed8a7757b305a7913ae3e03 out1.rds
d94afaebdeb954c9c4f16b965e151803 out2.rds

  • All
  • Subscribed
  • Moderated
  • Favorites
  • JUstTest
  • kavyap
  • thenastyranch
  • ethstaker
  • osvaldo12
  • mdbf
  • DreamBathrooms
  • InstantRegret
  • magazineikmin
  • Youngstown
  • ngwrru68w68
  • slotface
  • GTA5RPClips
  • rosin
  • megavids
  • cubers
  • everett
  • cisconetworking
  • tacticalgear
  • anitta
  • khanakhh
  • normalnudes
  • Durango
  • modclub
  • tester
  • provamag3
  • Leos
  • lostlight
  • All magazines