Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Real-World Anonymous Functions | Anonymous Functions in R
Functions and Functional Programming in R

bookChallenge: Real-World Anonymous Functions

Opgave

Swipe to start coding

Use your knowledge of anonymous functions and lapply to solve a practical data transformation problem.
Write a function capitalize_first that takes a list of names and returns a new list where each name has its first letter capitalized.

  • Use lapply to apply an anonymous function to each element of names_list.
  • The anonymous function should capitalize only the first letter of each name, leaving the rest unchanged.
  • The function must return a list with the transformed names.

Løsning

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 2. Kapitel 6
single

single

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

Suggested prompts:

Can you explain that in more detail?

What are the main benefits or drawbacks?

Can you give me an example?

close

bookChallenge: Real-World Anonymous Functions

Stryg for at vise menuen

Opgave

Swipe to start coding

Use your knowledge of anonymous functions and lapply to solve a practical data transformation problem.
Write a function capitalize_first that takes a list of names and returns a new list where each name has its first letter capitalized.

  • Use lapply to apply an anonymous function to each element of names_list.
  • The anonymous function should capitalize only the first letter of each name, leaving the rest unchanged.
  • The function must return a list with the transformed names.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 2. Kapitel 6
single

single

some-alt