Data Science & Statistics: Matrix operations in R

365 Data Science · Beginner ·🔢 Mathematical Foundations ·8y ago

Key Takeaways

The video covers matrix operations in R, including colSums, rowSums, colMeans, rowMeans, cbind, and rbind, to perform data science oriented operations.

Full Transcript

okay we covered matrix arithmetic which means the time has come to talk about some more data science oriented operations cool I'm almost certain that if you have our studio open as you're going through the lessons you will a grasp everything a lot better but that's a given and B have the matrix dot map data we created in the previous lesson loaded if you have started a new session and don't have the script from last time saved I have entered the code we used as comments so feel free to recreate the matrix because that's what we'll be using in this lesson all right so I have my matrix of US and worldwide box-office crossings for the Matrix movie franchise and I want to learn how much in total all three movies made at the box office both around the world and in the US only luckily there is the simplest command in our that lets me do that it's called cold sums and it returns the sum for each column in your data structure the only argument you need to pass is your data like this there these are the sums of all values in each of the two columns notice that the S for sums is capitalized remember that our is case-sensitive language if you don't use the proper capitalization x' or won't know what you want it to do right as you can probably guess if there is a called sums there will probably also be a row sums function just as it was with the call names and borough names and our bind and c bind and there is let's try it out even though it isn't too useful in our particular situation because one of our columns contains the worldwide box office figures and the other contains the US cross which is part of the worldwide statistic nonetheless now we have the total u.s. and worldwide grosses for each movie in the trilogy fantastic what if I wanted to know how much on average the movies made in the US and across the globe well I can use the coal means function it works exactly like columns but gives us the means for the columns in our data structure like this again be mindful of the capital M because R is case-sensitive awesome we can also do raw means and that will give us the averages for each row in the matrix and there it is we can now find out the sums and the means for columns in ravenna matrix that is super super useful when working with larger data and you want to get a quick feel for what it has in store for you often it will be useful to save the sums and averages you compute a separate rows and columns and add them to your data structure can you guess one way to do that I'll give you a couple of seconds of course you can save each output as a vector and then simply bind what you need displayed in the matrix with our bind and see bind let's try it out I will go back up and see if the columns and coal means results in two vectors called total and average and I will create a new matrix called matrix dot prelim with our bind and stick the two new vectors to the bottom of my data and there you have it a nice and neat little matrix that tells a number in front story excellent okay let's wrap it up here but before we go I have one final question the blue pill or the red pill you take the blue pill the story ends you wake up in your bed and believe whatever you want to believe you take the red pill you stay in our land and I will show you how deep the rabbit-hole goes for more videos like this one please subscribe

Original Description

👉🏻 Download Our Free Data Science Career Guide: https://bit.ly/348yU2u 👉🏻 FREE MONTH! Get full access to our newly redesigned platform and all our courses (18th October - 18th November): https://bit.ly/3l006WX Exploring a matrix's parameters in r: colSums, rowSums, colMeans, rowMeans, cbind, rbind. ColSums() returns the sum for each column in your data structure. The only argument you need to pass is your data. Just as it was with colnames() and rownames(), and cbind() and rbind(), there is a corresponding rowSums() function in R, too. It returns the sum for each row in a matrix. ColMeans() gives us the means for all columns in our matrix, and rowMeans() returns the averages of the rows in a matrix. ► Consider hitting the SUBSCRIBE button if you LIKE the content: https://www.youtube.com/c/365DataScience?sub_confirmation=1 ► VISIT our website: https://bit.ly/365ds 🤝 Connect with us LinkedIn: https://www.linkedin.com/company/365datascience/ 365 Data Science is an online educational career website that offers the incredible opportunity to find your way into the data science world no matter your previous knowledge and experience. We have prepared numerous courses that suit the needs of aspiring BI analysts, Data analysts and Data scientists. We at 365 Data Science are committed educators who believe that curiosity should not be hindered by inability to access good learning resources. This is why we focus all our efforts on creating high-quality educational content which anyone can access online. Check out our Data Science Career guides: https://www.youtube.com/playlist?list=PLaFfQroTgZnyQFq4nUfb-w2vEopN3ULMb #datascience #statistics #RProgramming
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from 365 Data Science · 365 Data Science · 42 of 60

1 Population vs Sample
Population vs Sample
365 Data Science
2 Data Science & Statistics: Levels of measurement
Data Science & Statistics: Levels of measurement
365 Data Science
3 Statistics Tutorials: Mean, median and mode
Statistics Tutorials: Mean, median and mode
365 Data Science
4 Skewness
Skewness
365 Data Science
5 What is a distribution?
What is a distribution?
365 Data Science
6 The Normal Distribution
The Normal Distribution
365 Data Science
7 Central limit theorem
Central limit theorem
365 Data Science
8 Student's T Distribution
Student's T Distribution
365 Data Science
9 Type I error vs Type II error
Type I error vs Type II error
365 Data Science
10 Hypothesis testing. Null vs alternative
Hypothesis testing. Null vs alternative
365 Data Science
11 The linear regression model
The linear regression model
365 Data Science
12 Simple linear regression model. Geometrical representation
Simple linear regression model. Geometrical representation
365 Data Science
13 INDEX and MATCH application of the two functions separately and combined [Advanced Excel]
INDEX and MATCH application of the two functions separately and combined [Advanced Excel]
365 Data Science
14 INDIRECT Excel Function: How it works and when to use it [Advanced Excel]
INDIRECT Excel Function: How it works and when to use it [Advanced Excel]
365 Data Science
15 VLOOKUP and MATCH another useful functions combination [Advanced Excel]
VLOOKUP and MATCH another useful functions combination [Advanced Excel]
365 Data Science
16 VLOOKUP COLUMN and ROW - Handle large data tables with ease [Advanced Excel]
VLOOKUP COLUMN and ROW - Handle large data tables with ease [Advanced Excel]
365 Data Science
17 The ELIF keyword [Python Fundamentals]
The ELIF keyword [Python Fundamentals]
365 Data Science
18 Working with Tuples in Python
Working with Tuples in Python
365 Data Science
19 Database Terminology - A Beginners Guide
Database Terminology - A Beginners Guide
365 Data Science
20 Relational Database Essentials
Relational Database Essentials
365 Data Science
21 Database vs Spreadsheet - Advantages and Disadvantages
Database vs Spreadsheet - Advantages and Disadvantages
365 Data Science
22 Conditional Statements and Loops
Conditional Statements and Loops
365 Data Science
23 Backpropagation – The Math Behind Optimization
Backpropagation – The Math Behind Optimization
365 Data Science
24 Monte Carlo: Forecasting Stock Prices Part I
Monte Carlo: Forecasting Stock Prices Part I
365 Data Science
25 Monte Carlo: Forecasting Stock Prices Part II
Monte Carlo: Forecasting Stock Prices Part II
365 Data Science
26 Monte Carlo: Forecasting Stock Prices Part III
Monte Carlo: Forecasting Stock Prices Part III
365 Data Science
27 365 Data Science Online Program
365 Data Science Online Program
365 Data Science
28 Data frames - Creating a data frame
Data frames - Creating a data frame
365 Data Science
29 Data Science & Statistics: Slicing a matrix in R
Data Science & Statistics: Slicing a matrix in R
365 Data Science
30 Data frames in R - Exporting data in R
Data frames in R - Exporting data in R
365 Data Science
31 Data frames in R - Transforming data PART II
Data frames in R - Transforming data PART II
365 Data Science
32 Data Frames in R - Subsetting a data frame
Data Frames in R - Subsetting a data frame
365 Data Science
33 Data Science & Statistics: Matrix arithmetic in R
Data Science & Statistics: Matrix arithmetic in R
365 Data Science
34 Data Science & Statistics: Indexing an element from a matrix
Data Science & Statistics: Indexing an element from a matrix
365 Data Science
35 Data Frames in R - Extending a data frame
Data Frames in R - Extending a data frame
365 Data Science
36 Data Science & Statistics: Creating a matrix in R FASTER
Data Science & Statistics: Creating a matrix in R FASTER
365 Data Science
37 Data Science & Statistics: Creating a Matrix in R
Data Science & Statistics: Creating a Matrix in R
365 Data Science
38 Data frames - Importing data in R
Data frames - Importing data in R
365 Data Science
39 Data frames in R - Getting a sense of your data
Data frames in R - Getting a sense of your data
365 Data Science
40 Data frames in R - Transforming data PART I
Data frames in R - Transforming data PART I
365 Data Science
41 Data frames in R - Import a CSV in R
Data frames in R - Import a CSV in R
365 Data Science
Data Science & Statistics: Matrix operations in R
Data Science & Statistics: Matrix operations in R
365 Data Science
43 Data Science & Statistics: Matrix recycling in R
Data Science & Statistics: Matrix recycling in R
365 Data Science
44 Tableau vs Excel: When to use Tableau and when to use Excel
Tableau vs Excel: When to use Tableau and when to use Excel
365 Data Science
45 Download Tableau: Learn how to download Tableau Public
Download Tableau: Learn how to download Tableau Public
365 Data Science
46 Connecting data sources: Useful tips when connecting data sources to Tableau
Connecting data sources: Useful tips when connecting data sources to Tableau
365 Data Science
47 The Tableau interface: See how to navigate through the Tableau interface
The Tableau interface: See how to navigate through the Tableau interface
365 Data Science
48 Tableau data visualization: Create your first Tableau visualization!
Tableau data visualization: Create your first Tableau visualization!
365 Data Science
49 Duplicating sheets: This is how to duplicate a sheet in Tableau
Duplicating sheets: This is how to duplicate a sheet in Tableau
365 Data Science
50 Build a table in Tableau: The steps needed to create a simple table in Tableau
Build a table in Tableau: The steps needed to create a simple table in Tableau
365 Data Science
51 Custom fields in Tableau: Using Tableau operators to create custom fields
Custom fields in Tableau: Using Tableau operators to create custom fields
365 Data Science
52 Custom fields in Tableau: Add calculations to tables through custom fields
Custom fields in Tableau: Add calculations to tables through custom fields
365 Data Science
53 Totals in Tableau: Learn how to display subtotals and totals in Tableau
Totals in Tableau: Learn how to display subtotals and totals in Tableau
365 Data Science
54 Gross Margin calculation in Tableau
Gross Margin calculation in Tableau
365 Data Science
55 What is a filter in Tableau: Set up a filter in Tableau to specify the data you want to show
What is a filter in Tableau: Set up a filter in Tableau to specify the data you want to show
365 Data Science
56 Joins in Tableau: Inner, outer, left, or a right join in Tableau
Joins in Tableau: Inner, outer, left, or a right join in Tableau
365 Data Science
57 Building a Tableau dashboard: Three types of charts you want to have in a Tableau dashboard
Building a Tableau dashboard: Three types of charts you want to have in a Tableau dashboard
365 Data Science
58 Creating great looking charts in Tableau: Real life Exercise on charts in Tableau
Creating great looking charts in Tableau: Real life Exercise on charts in Tableau
365 Data Science
59 Joins in Tableau: Choose the correct join type
Joins in Tableau: Choose the correct join type
365 Data Science
60 How to make a data check in Tableau: A quick data check is better than no data check
How to make a data check in Tableau: A quick data check is better than no data check
365 Data Science

This video teaches matrix operations in R, including calculating column and row sums and means, and binding new vectors to a matrix. It provides a foundation for data science and statistical analysis in R.

Key Takeaways
  1. Load a matrix in R
  2. Use colSums to calculate column sums
  3. Use rowSums to calculate row sums
  4. Use colMeans to calculate column means
  5. Use rowMeans to calculate row means
  6. Use cbind and rbind to bind new vectors to a matrix
💡 Matrix operations in R can be used to perform data science oriented operations, such as calculating sums and means, and binding new data to a matrix.

Related Reads

Up next
How to Open OSM Files (OpenStreetMap Data)
File Extension Geeks
Watch →