IN THIS CHAPTER
Defining a vector and naming a range
Operating on vectors and ranges
Importing a table from Excel into R
Excel, the most widely used spreadsheet program, has an impressive array of statistical analysis tools. Although some have characterized Excel as the Rodney Dangerfield of analysis software (“don’t get no respect!”), a lot of people use Excel’s analysis tools. (And believe me, no one is happier about that than I am!)
If you’re one of those people and you need a bit of help transitioning to R, this chapter is for you. I point out similarities and differences that might help you make the leap.
Here’s a standard, everyday garden-variety vector in R:
x <- c(15,16,17,18,19,20)
If you’re used to naming arrays in Excel, you’ve already done something like this. Figure 19-1 shows a spreadsheet with these numbers in cells F2 through F7 and headed by x in F1. The figure also shows the New Name dialog box that opens when I highlight that range, right-click, and select Define Name from the menu that pops up. Clicking OK defines x as the name of that range, just as the R statement creates ...