Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Challenge: Inline Functions with apply | Anonymous Functions in R
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Functions and Functional Programming in R

bookChallenge: Inline Functions with apply

Aufgabe

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"

Lösung

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 2. Kapitel 4
single

single

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

Suggested prompts:

Can you explain this in simpler terms?

What are the main benefits or drawbacks?

Can you give me a real-world example?

close

bookChallenge: Inline Functions with apply

Swipe um das Menü anzuzeigen

Aufgabe

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"

Lösung

Switch to desktopWechseln Sie zum Desktop, um in der realen Welt zu übenFahren Sie dort fort, wo Sie sind, indem Sie eine der folgenden Optionen verwenden
War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 2. Kapitel 4
single

single

some-alt