Placeholder Image

字幕表 動画を再生する

  • Hi, everybody, and welcome back.

  • Okay, So from Victor's to changing them entrance to matrices and data frames, we have gone a long way already, and in this lesson we are getting a step closer to data frames because we'll be focusing on matrices.

  • You already know what a matrix is.

  • You're so one.

  • In the previous lesson, we made a one dimensional object, an atomic vector eloquently called a into a two dimensional matrix, still eloquently called a by giving it a dimensions argument.

  • What does this tell us about matrices?

  • Well, a few things first, when it comes to storing data, matrices are a natural extension to Victor's.

  • While Victor's air one dimensional collections of data matrices are two dimensional, Ari's two matrices have a fixed number of rows and columns, and three matrices, in the same way as vectors, can contain only one basic data type.

  • This makes sense.

  • You create a matrix from a victor.

  • You can think of it as a curving of victor into rose or columns, and just as a victor can literally store doubles characters or logic ALS, so can a matrix.

  • All right, let's learn to new methods for creating a matrix.

  • The major X function in the are behind and see bind functions.

  • Using the major X function to create a matrix is very straightforward.

  • Matrix takes at least two arguments.

  • Victor.

  • It can structure into a matrix and an argument specifying the number of rows the new object must have called in a row.

  • Alternatively, you can pass the number of columns you want your matrix to have by specifying in coal.

  • Finally, you pick out a name for your matrix and save it to an object.

  • So my Matrix is gold MTR eggs and it contains the numbers from 1 to 12 I said and wrote 23 So you can see our inference that since I have 12 values in my victor, I probably want four columns.

  • If I said ankle to before and leave and Roland specified, we'll still get the same result for Mt.

  • Rx.

  • Awesome!

  • All right, so I have mentioned in the previous lesson that when we use the major X function will be able to decide the way our data is organized into a matrix.

  • So what does that mean?

  • Well, notice how the sequence of values ISS entered by columns Our starts by filling the first column, then moves on to the second and so on.

  • What if I wanted my data to be organized by row?

  • However Well, if that's the case, I can use the buyer Oh, arguments in the matrix function and said it too.

  • True, instead of its default folks like this print Mt.

  • Eriks.

  • Oh, that looks nicer.

  • Right?

  • Okay, So I mentioned there is another way to create a matrix in our and that is with the r Bind and see bind functions.

  • Our bind stands for row, bind and sit behind.

  • You guessed it for Columbine.

  • These methods often seem more intuitive to people.

  • But if you grasp the matrix function well enough, it will serve you just as well.

  • Okay, so let's create two new vectors.

  • I will call the 1st 1 USA and never possum numbers into it.

  • 1.31 point 51.21 point four and 1.5.

  • I will create a second factor called d E, and it will hold the numbers.

  • 0.20 point for 0.70 point eight and 0.8 Again.

  • Fantastic.

  • These are just made up numbers reflecting the amount of non government organizations in the U.

  • S.

  • A.

  • And in Germany in millions.

  • Now that I have my data ready, I can bind it into a matrix.

  • Let's use the sea bind to do that.

  • NGO.

  • This is the name I want my matrix to half see blind and in the parentheses.

  • I will pass the vectors.

  • I won't find it.

  • Print NGO to see how that worked and it worked beautifully.

  • Fantastic.

  • Okay, notice how the bind function took the names of the victors and bind it and save them of the column names.

  • Well, you can change that if that doesn't work for you.

  • But first, let's give names to our nameless Rose.

  • Naming the components of The Matrix is just like naming a victor.

  • But instead of using the names function matrices recognized the coal names and roll names functions.

  • Let's try row names Pastor Data and create a vector of row names.

  • Print the Matrix again.

  • Now that is a lot more informative than before, don't you think?

  • Okay, there's just one problem.

  • I would very much prefer to have my years as columns and the data points as rose, but I don't want to do the whole thing all over again.

  • Okay?

  • Luckily, there is the transposed based function that lets has changed the orientation of her data.

  • Okay, I'm just gonna go ahead and I'm going to save my NGO Matrix as its transposed version and very have it a fuller named and operational matrix.

  • And if I wanted to enter another role for the data, for instance about India's NGOs, I could easily do it with E r.

  • Bind function like this.

  • There you go.

  • Another row.

  • I did virtually effortlessly.

  • Okay, Awesome.

  • Fantastic.

  • Let's wrap it up here.

  • And the next lesson will be more on the practical side of things.

  • So I'm gonna catch you there form or videos like this one, please subscribe.

Hi, everybody, and welcome back.

字幕と単語

ワンタップで英和辞典検索 単語をクリックすると、意味が表示されます

B1 中級

データサイエンスと統計学。Rでマトリックスを作成する (Data Science & Statistics: Creating a Matrix in R)

  • 0 0
    林宜悉 に公開 2021 年 01 月 14 日
動画の中の単語