3. Wk2_DataTypesVectorsAndSubsets2013

Age position 1 3 7 8 73 33 79 47 27 33 67 52 59 27 55

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ubset by name j 71 •  Genders of the family members who are over weight > fgender[foverWt] Subset by logical [1] m f m m m f Levels: m f Assign values to elements of a vector •  In general, the same indexing may be used to assign values to elements of a vector. •  Make sure the vector exists first, or you will get an error. Assign values to elements of a vector Can you guess what veight will look like awer each of the following lines? > veight a b c d e f g h i j k l m n 70 64 73 67 64 68 68 65 68 71 67 66 66 62 fheight[2] = 61 fheight[-13] = 62 fheight["e"] = 67 fheight[overWt] = NA fheight = 70 fheight = 70 # # # # # # By inclusion By exclusion By name By logical No index Watch out! a b c d e f g h i j k l m n 70 64 73 67 64 68 68 65 68 71 67 66 66 62 fheight[2] = 61 a b c d e f g h i j k l m n 70 61 73 67 64 68 68 65 68 71 67 66 66 62 fheight[-13] = 62 a b c d e f g h i j k l m n 62 62 62 62 62 62 62 62 62 62 62 62 66 62 fheight["e"] = 67 a b c d e f g h i j k l m n 62 62 62 62 67 62 62 62 62 62 62 62 66 62 T F F F F T T F T T T F F F fheight[foverWt] = NA a b c d e f g h i j k l m n NA 62 62 62 67 NA NA 62 NA NA NA 62 66 62 fheight = 70 a b c d e f g h i j k l m n 70 70 70 70 70 70 70 70 70 70 70 70 70 70 fheight = 70 [1] 70 Suppose we want the: •  BMI of every other person in the family Subset using a vector of posi6ons •  Weights of the women in our family Subset using a logical vector •  Height elements “a”, “c”, “f” Subset with character vector of element names •  Assign every one in the family the last name of “Smith” Create an empty vector and assign all elements We nee...
View Full Document

This document was uploaded on 02/16/2014 for the course STATISTICS 3026 at Columbia.

Ask a homework question - tutors are online