12.07.2015 Views

R dummies

R dummies

R dummies

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

time, %in% is in infix operator. An infix operator in R is identifiable by thepercent signs around the function name. If you want to know how %in% isdefined, look at the details section of its Help page. But note that you have toplace quotation marks around the function name to get the Help page, likethis: ?”%in%”.Sorting and Ordering DataOne very common task in data analysis and reporting is sorting information.You can answer many everyday questions with league tables — sorted tables ofdata that tell you the best or worst of specific things. For example, parents want toknow which school in their area is the best, and businesses need to know the mostproductive factories or the most lucrative sales areas. When you have the data, youcan answer all these questions simply by sorting it.As an example, look again at the built-in data about the states in the U.S.First, create a data frame called some.states that contains information contained inthe built-in variables state.region and state.x77:> some.states some.states some.statesRegion Population IncomeAlabama South 3615 3624Alaska West 365 6315Arizona West 2212 4530....Delaware South 579 4809Florida South 8277 4815Georgia South 4931 4091You now have a variable called some.states that is a data frame consisting often rows and three columns (Region, Population, and Income).Sorting vectors

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!