Get startedGet started for free

Grain yields and unit conversion

1. Grain yields and unit conversion

Three chapters in, and you've covered most of the theory on how to write a function, and how to make it a good one. Now it's time to have fun and use your new skills to analyze some datasets.

2. USDA NASS

In this chapter, you'll be exploring historic grain yield data provided by the National Agricultural Statistics Service, part of the United States Department of Agriculture.

3. Corn and wheat

To start with, you'll get to play with the corn and wheat datasets. Here's some corn and some wheat. Don't you wish you were in a field right now? It's a great dataset, but unfortunately the areas and grain yields are in US units, so you'll have to convert them to metric units.

4. 1 acre = area of land 2 oxen can plough in a day

The areas are given in acres. One acre is the amount of land that a pair of oxen can plough in one day.

5. Not the 100 Acre Wood

To visualize an acre, I wanted to show you a picture of the One Hundred Acre Wood, home of Winnie the Pooh. Unfortunately, Disney own the rights to those images, so you'll have to make do with a photo of Ashdown Forest in England, which was the original inspiration for the One Hundred Acre Wood. So one acre is zero-point-zero-one of what you see here, I guess.

6. 1 hectare = 2 football fields

You'll be converting the area units to hectares, which is one hundred meters by one hundred meters. That's about two US football fields,

7. 1 hectare = 150 New York apartments

or one hundred and fifty New York Apartments.

8. 1 bushel = 2 baskets of peaches

The grain yield values are given in bushels per acre. A bushel used to be a measure of volume equal to eight gallons. Each basket containing peaches is half a bushel.

9. 1 kilogram = 1 squirrel monkey

You'll be converting the masses in bushels to kilograms. One kilogram is about the mass of a squirrel monkey.

10. magrittr's pipeable operator replacements

OK, time for some code. The code in each column is interchangeable, except that the operators on the left aren't very easy to use in a chain of pipes. The magrittr package has some functions that replace arithmetic and subsetting operators, in order to make your code more pipe friendly. multiply_by, raise_to_power, and extract will come in handy in the following exercises.

11. Let's practice!

Time to convert some units!

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.