MulaiMulai sekarang secara gratis

How to write compose()

When you use compose(), the functions are passed from right to left — that is to say in the same order as the one you would use in a nested call in base R: the first function to be executed is the function on the right.

In other words, if you are used to the pipe, the order is the opposite one:

``` r

With the pipe

1:28 %>% mean() %>% round()

In base R

round(mean(1:28))

With compose

roundedmean <- compose(round, mean) rounded< em>mean(1:28) ```

So, what's the correct way to write a function that will count the number of NA?

Latihan ini adalah bagian dari kursus

Intermediate Functional Programming with purrr

Lihat Kursus

Latihan interaktif praktis

Ubah teori menjadi tindakan dengan salah satu latihan interaktif kami.

Mulai berolahraga