Challenge: Inline Functions with apply
Opgave
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"
Løsning
Var alt klart?
Tak for dine kommentarer!
Sektion 2. Kapitel 4
single
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat
Fantastisk!
Completion rate forbedret til 5.56
Challenge: Inline Functions with apply
Stryg for at vise menuen
Opgave
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"
Løsning
Var alt klart?
Tak for dine kommentarer!
Sektion 2. Kapitel 4
single