Challenge: Inline Functions with apply
Task
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_signthat take a list. - Use
sapplywith 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"
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 2. ChapterΒ 4
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Suggested prompts:
Can you explain this in simpler terms?
What are the main benefits or drawbacks?
Can you give me a real-world example?
Awesome!
Completion rate improved to 5.56
Challenge: Inline Functions with apply
Swipe to show menu
Task
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_signthat take a list. - Use
sapplywith 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"
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 2. ChapterΒ 4
single