Map and Anonymous Functions

In this mission, you’ll learn about map and anonymous functions, two techniques you can use to turbo-charge your data cleaning in R.

You’ll learn how to work with data in the JavaScript Object Notation (JSON) format, which is commonly used for data acquired via web APIs (for more on working with APIs, check out our API course). As you work with JSON data, you learn to use the jsonlite library in R. This library has built-in functions that make it easy to work with JSON data using Python code.

As you work with this JSON data, you will also learn about mapper functions and how it can be used to clean up your code and make it easier to read. Map functions can be used to do things like iterate over values in a list, perform a transformation on those values, and assign the result to a new list all on one line of code! After you learn about vectorization, you will learn about anonymous functions: temporary functions that can also be declared in a single line of code to save time.

In this mission, you will continue working with data from Hacker News as you practice using regular expressions and apply your new skills with map and anonymous functions. By the end of this mission, you’ll be comfortable working with JSON data, and using mapper and anonymous functions to speed up your data cleaning.


  • Read and work with JSON files.
  • Learn to use mapper functions to easily create and transform lists.
  • Learn to create and use anonymous functions.

Lesson Outline

  1. The JSON Format
  2. Reading a JSON file
  3. Deleting Variables From a Dataframe
  4. Map Functions
  5. Using Map Functions to Handle Our Dataframe
  6. Anonymous Functions
  7. Using Anonymous Functions to Handle Our Dataframe
  8. Challenge: Cleaning Our Dataframe
  9. Next Steps
  10. Takeaways

Get started for free

No credit card required.

Or With

By creating an account you agree to accept our terms of use and privacy policy.