Slicing and dicing datasets

Our first example is to pick all stocks listed on the NYSE by using an R dataset called marketCap.Rdata, shown in the code here:

> con<-url("http://canisius.edu/~yany/RData/marketCap.RData") 
> load(con) 
> head(.marketCap) 

The associated output is shown here:

> head(.marketCap) 
  Symbol                       Name MarketCap Exchange 
1      A Agilent Technologies, Inc. $12,852.3     NYSE 
2     AA                 Alcoa Inc. $28,234.5     NYSE 
3   AA-P                 Alcoa Inc.     $43.6     AMEX4    AAC       Ableauctions.Com Inc      $4.3     AMEX 
5    AAI     AirTran Holdings, Inc.    $156.9     NYSE 
6    AAP     Advance Auto Parts Inc  $3,507.4     NYSE 

We have various ways to choose a subset of the R dataset called .marketCap. Note that there is a dot in front of .marketCap:

a<-.marketCap[1] # choose the 1st column b<-.marketCap$SYMBOL ...

Get Hands-On Data Science with Anaconda now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.