flâneur — a map of the web's best reading

8.1. Applying a Function to a Column — Computational and Inferential Thinking

inferentialthinking.com · 4 words · saved by 1 readers

We have seen many examples of creating new columns of tables by applying functions to existing columns or to other arrays. All of those functions took arrays as their arguments. But frequently we will want to convert the entries in a column by a function that doesn’t take an array as its argument. For example, it might take just one number as its argument, as in the function cut_off_at_100 defined below. The function cut_off_at_100 simply returns its argument if the argument is less than or equal to 100. But if the argument is greater than 100, it returns 100. In our earlier examples using Census data, we saw that the variable AGE had a value 100 that meant “100 years old or older”. Cutting off ages at 100 in this manner is exactly what cut_off_at_100 does. To use this function on many ages at once, we will have to be able to refer to the function itself, without actually calling it. Analogously, we might show a cake recipe to a chef and ask her to use it to bake 6 cakes. In that scena

Redirecting... Redirecting to https://inferentialthinking.com/chapters/08/1/applying-a-function-to-a-column/index.html

Explore this link on the map →

related reading