Challenge: Inline Functions with apply
Taak
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"
Oplossing
Was alles duidelijk?
Bedankt voor je feedback!
Sectie 2. Hoofdstuk 4
single
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.
Suggested prompts:
Can you explain this in simpler terms?
What are the main benefits or drawbacks?
Can you give me a real-world example?
Geweldig!
Completion tarief verbeterd naar 5.56
Challenge: Inline Functions with apply
Veeg om het menu te tonen
Taak
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"
Oplossing
Was alles duidelijk?
Bedankt voor je feedback!
Sectie 2. Hoofdstuk 4
single