No video

R and Rust - getting started with extendr

  Рет қаралды 1,773

Josiah Parry

Josiah Parry

Күн бұрын

Write R packages using Rust.
Rust is fast, type safe, and memory efficient.
The rextendr R package and extendr rust crate lets you interact with R objects and Rust objects at the same time.
Start making R packages faster by writing extendr libraries.
This video will show you the absolute basics.
If you don't know rust, this might help make a bit more sense of it. But it is by no means a guide to Rust.
{rexetendr} R package - github.com/ext...
extendr Rust library - extendr.github...
Rcpp - www.rcpp.org/
cpp11 - cpp11.r-lib.org/
usethis - usethis.r-lib....
Github - github.com/jos...
Blog - josiahparry.com/

Пікірлер: 14
@user-hl1fk6lw8k
@user-hl1fk6lw8k 3 ай бұрын
Thanks for the intuitive tutorial. But I would like to point out that str::len() method counts bytes instead of characters. Non-alphanumerical characters will return inappropriate results, i.e. nchar2("你好世界") (Hello World in Chinese) returns 12 instead of 4. Interestingly, NA values are 2 bytes. One should use str::chars().count() to count at a higher computation cost than str::len().
@aswanijehangeer
@aswanijehangeer 7 ай бұрын
Such a nice video, Josiah. Since I'm a statistics graduate and have used R a lot, I found this video to be very useful for learning how to use extender package and rust with R.
@stewartli5395
@stewartli5395 Жыл бұрын
read my mind. thank you so much for the video. :)
@lanceferrer9023
@lanceferrer9023 4 ай бұрын
what happens if your function returns Vec, where T is, say, struct Person { name: String , age: i32 }?
@josiahparry
@josiahparry 4 ай бұрын
You'll need to make sure that the struct is compatible with R using the #[extendr] attribute macro on the structs impl. Then, if you plan on returning the result to R, you should collect them as a list instead of Vec. We need to think with two hats on at the same time: Rust and R. R doesn't have arbitrary types. It does, though, let you store a list of external pointers and thats what #[extendr] does. See: extendr.github.io/user-guide/extendr-macro.html#exporting-impl-blocks You might have some code like x.iter().map(|xi| { make Person }).collect::() I do this extensively in github.com/JosiahParry/rsgeo/
@howardbaek5413
@howardbaek5413 Жыл бұрын
Really engaging and informative. Thanks for sharing.
@vitygas
@vitygas Жыл бұрын
Hi - thank you. I am a bit confused by your penultimate part showing how to deal with NAs. You create the function that is NA aware, but at kzbin.info/www/bejne/qoPQXoSnZ8R0ppI you are calling add2, not the new function. Also, if this is Rust -> C -> R, is it faster to write in C? or are we getting compiler goodies that mitigate that?
@RuchiraDatta
@RuchiraDatta 3 ай бұрын
I also have the same question about using add2! And also, why does it work?
@en1766
@en1766 9 ай бұрын
love your content, please keep it up!
@joshstat8114
@joshstat8114 6 ай бұрын
Is there any cookbook for `extendr` and `rextendr`? Also, how to set up `extendr` or `extendrsrc` in R markdown? When I run a chunk in extendr, it works and saved in environment however, when I knit the rmd file, it failed
@en1766
@en1766 9 ай бұрын
can you make a video about how to interface between R OOP Systems (e.g. S4) and Rust?
@Kersich86
@Kersich86 Жыл бұрын
idk how this came into my feed but anyway. not specific to this video but i never understood the use case for this kind of trans language interfaces. every time i see them used in practice its just screams bad idea. also they are always jenky at best and showcased with like add functions. when you need to do something in practice then all hell breaks loose. and god forbid you need to debug something😂
@josiahparry
@josiahparry Жыл бұрын
lol well it's cool that it found you! The case is somewhat as I described. Other languages like C++, Rust, C, and Fortran even (in the case of R) are far more performant than langauges like R or Python. As a result things that need to be performant are often written in those low level languages and bindings for more higher level languages are provided. A great example is definitely deep learning frameworks. Tensorflow is written in C++ but its called from their language bindings in Python. Torch for example is written (i think) in C and there are bindings to it from R and Python. In the geospatial world GDAL and GEOS rule. No one in the right mind would rewrite those libraries from scratch lol. So just about every language has bindings to them. Debugging definitely can be tricky! But the nice thing about rust is that the compiler is bang on just about all the time!
@Japhir13
@Japhir13 5 ай бұрын
Would love to see a similar video where you set up C interop. I'm writing a package that should interface with some C code that someone else wrote but I can almost exclusively find C++ sources
Rust & R: Decoding Geohashes into sf objects | Pt. 2
10:00
Josiah Parry
Рет қаралды 219
OMG what happened??😳 filaretiki family✨ #social
01:00
Filaretiki
Рет қаралды 12 МЛН
Вы чего бл….🤣🤣🙏🏽🙏🏽🙏🏽
00:18
Look at two different videos 😁 @karina-kola
00:11
Andrey Grechka
Рет қаралды 14 МЛН
Happy birthday to you by Tsuriki Show
00:12
Tsuriki Show
Рет қаралды 10 МЛН
Making R 300x times faster!
21:28
Josiah Parry
Рет қаралды 4,5 М.
Parse Rust CLI Args With Clap 🦀 Rust Tutorial
54:03
Trevor Sullivan
Рет қаралды 11 М.
1 billion row challenge in Rust using Apache Arrow
9:12
Josiah Parry
Рет қаралды 9 М.
iced GUI | Rust Language
17:00
Learning Rust
Рет қаралды 4,9 М.
Claus Wilke - The extendr project: Integrating R and Rust
1:43:55
Lander Analytics
Рет қаралды 1,5 М.
Mo Bitar - Rust vs Julia in scientific computing
7:43
Scientific Computing in Rust
Рет қаралды 5 М.
Demystifying . . . (dots): R package dev fundamentals
10:08
Josiah Parry
Рет қаралды 2 М.
OMG what happened??😳 filaretiki family✨ #social
01:00
Filaretiki
Рет қаралды 12 МЛН