Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Challenge: Inline Functions with apply | Anonymous Functions in R
Functions and Functional Programming in R

bookChallenge: Inline Functions with apply

Tehtävä

Swipe to start coding

Use your understanding of anonymous functions and the apply family to classify each element in a numeric vector as "positive", "negative", or "zero".

  • Create function determine_sign that take a list.
  • Use sapply with an anonymous function to process each element of the input vector.
  • The function must return a character vector of the same length as the input, with each element classified as "positive", "negative", or "zero".

The result for (3, -2, 0, 7, -5) should look like:

"positive" "negative" "zero" "positive" "negative"

Ratkaisu

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 2. Luku 4
single

single

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

close

bookChallenge: Inline Functions with apply

Pyyhkäise näyttääksesi valikon

Tehtävä

Swipe to start coding

Use your understanding of anonymous functions and the apply family to classify each element in a numeric vector as "positive", "negative", or "zero".

  • Create function determine_sign that take a list.
  • Use sapply with an anonymous function to process each element of the input vector.
  • The function must return a character vector of the same length as the input, with each element classified as "positive", "negative", or "zero".

The result for (3, -2, 0, 7, -5) should look like:

"positive" "negative" "zero" "positive" "negative"

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 2. Luku 4
single

single

some-alt