Okay, SofromVictor's tochangingthementrancetomatricesanddataframes, wehavegone a longwayalready, andinthislessonwearegetting a stepclosertodataframesbecausewe'llbefocusingonmatrices.
Youalreadyknowwhat a matrixis.
You'resoone.
Inthepreviouslesson, wemade a onedimensionalobject, anatomicvectoreloquentlycalled a into a twodimensionalmatrix, stilleloquentlycalled a bygivingit a dimensionsargument.
Whatdoesthistellusaboutmatrices?
Well, a fewthingsfirst, whenitcomestostoringdata, matricesare a naturalextensiontoVictor's.
WhileVictor's aironedimensionalcollectionsofdatamatricesaretwodimensional, Ari's twomatriceshave a fixednumberofrowsandcolumns, andthreematrices, inthesamewayasvectors, cancontainonlyonebasicdatatype.
Thismakessense.
Youcreate a matrixfrom a victor.
Youcanthinkofitas a curvingofvictorintoroseorcolumns, andjustas a victorcanliterallystoredoublescharactersorlogicALS, socan a matrix.
Allright, let's learntonewmethodsforcreating a matrix.
Themajor X functioninthearebehindandseebindfunctions.
Usingthemajor X functiontocreate a matrixisverystraightforward.
Matrixtakesatleasttwoarguments.
Victor.
Itcanstructureinto a matrixandanargumentspecifyingthenumberofrowsthenewobjectmusthavecalledin a row.
Finally, youpickout a nameforyourmatrixandsaveittoanobject.
SomyMatrixisgoldMTReggsanditcontainsthenumbersfrom 1 to 12 I saidandwrote 23 Soyoucanseeourinferencethatsince I have 12 valuesinmyvictor, I probablywantfourcolumns.
If I saidankletobeforeandleaveandRolandspecified, we'llstillgetthesameresultforMt.
Rx.
Awesome!
Allright, so I havementionedinthepreviouslessonthatwhenweusethemajor X functionwillbeabletodecidethewayourdataisorganizedinto a matrix.