concept anything in category R

appears as: nything, Anything
Beyond Spreadsheets with R

This is an excerpt from Manning's book Beyond Spreadsheets with R.

Data isn’t always pretty (in fact, most times it’s dirty, mundane, and seemingly uninteresting), and it isn’t always in the format we want. Having some tools on hand to manage data is a powerful advantage and is critical to achieving a reliable goal, but that’s only useful if you know what your data represents before you do anything further with it. “Garbage in, garbage out” warns that you can’t perform an analysis on terrible data and expect to get a meaningful result. You may very well have tried to evaluate a calculation in Excel only to have the result show up as #VALUE! because you tried to divide a number by some text, even though that “text” looked like numbers. The types of your values (text, numbers, images, and so on) are themselves pieces of data with possible meanings behind them, and you’ll learn how to best make use of them.

Comparison between the two logical values can be summarized in a truth table, where the intersection of a row and a column shows the result of the comparison row == column, as shown in table 3.1. Notice that comparing anything to NA yields NA, including NA itself.

Table 3.1 Truth table for the equals operator ( ==) (view table figure)
== TRUE FALSE NA
TRUE TRUE FALSE NA
FALSE FALSE TRUE NA
NA NA NA NA

Comparing anything to NULL results in nothing, but a particular “type” of nothing — still a logical value, but one that is of length 0:

# install.packages("purrr")
library(purrr)
## walk is equivalent to map but doesn't return anything explicitly
##   (actually returns the input list, invisibly)
walk(car_cyls, showcase)
#> There are 11 cars with 4 cylinders.
#> The most fuel efficient of these is the Toyota Corolla
#>
#> There are 7 cars with 6 cylinders.
#> The most fuel efficient of these is the Hornet 4 Drive
#>
#> There are 14 cars with 8 cylinders.
#> The most fuel efficient of these is the Pontiac Firebird