PADP 7120 Chapter Notes - Chapter 2: Subset
Document Summary
Lecture 2 : data manipulation & summary statistics: accessing & manipulating variables, load a data set. Note what r names of the dataset in the global environment : 2 methods accessing a dataset (1) $ method. Use formula dataset to create a new variable from a variable within the dataset. Ex. dataset of gubernatorial election called gagovdata: new variable = dataset&variable in dataset , vote share = gagovdata/gagovdata. votes (2) attach method. Easier method but confusing with multiple datasets loaded with similar variable names. Ex. adding vote share variable & its data to gagovdata dataset: gagovdata = data. frame(gagovdata, vote share, to identify subsets of variables data. Each observation of each variable in r can be accessed via an index number: variable[observation #, ex. vote share of person 2. Vote share [2: variable [row, column, ex. all of column 3 of the gagovdata dataset. **a blank can be left to indicate all of the rows/columns be included)