Showing posts with label Matrix. Show all posts
Showing posts with label Matrix. Show all posts

Wednesday, June 20, 2018

What are rbind and cbind for matrices in R?

rbind is short for row bind. rbind binds concatenated datapoints into matrix of compatible dimensions. cbind does the same taking column data.

Let us take the matrix defined in an earlier post:


MTX_0

In the above the matrix is:
     [,1] [,2] [,3]
[1,]    1    2    3
[2,]    4    5    6
[3,]    7    8    9

This has three rows. Let us define the following:

row1=c(1,2,3)
row2=c(4,5,6)
row3=c(7,8,9)


We can define the same matrix using rbind as shown below.

mtx2=rbind(row1,row2,row3)
Then we can form the matrix using the rbind as shown here:


MTX_1
 
There is a slight difference in the displayed results. However, you can perform this to get the matrix displayed in the original format as shown here:


MTX_2

The cbind works the same way as rbind. Instead of binding row-wise you bind column-wise. Of course you need to use the columns correctly.


MTX_3

Monday, June 18, 2018

How do you represent a 3x3 matrix in R?

Matrix (matrices) is a data type in R used in many mathematical problems. A matrix has rows and columns. A 3 by 3 matrix has 3 rows and 3 columns. A matrix can have only columns, only rows and both columns and rows.

Here is an example of a 3x 3 matrix.

1, 2, 3
4, 5, 6
7, 8, 9

Let us create a matrix which is obtained by arranging the data, a vector of values 1,2,3,4,5,6,7,8,9 by assigning three elements each to a row and create 3 columns from the rows. This is how you do it in R.

Matrix_1

If you want to find the elements of this matrix, you provide the row and column where your element is found as shown.

You find 5 in the 2nd row and 2nd column and you find 6 in 2nd row and 3rd column.

Matrix_2
How do you arrange the same vectors column-wise arranged. You use the same definition as in the previous but omit, byrow attribute as shown.

Matrix_3

This is just the basic but you can do a whole lot more using R.

Saturday, December 19, 2015

Which of Firefox and Microsoft Edge support MathML better?

This is just the view point looking at just one example and must not be construed to apply to whole of MathML. You may review some basic MathML information here.

Here is an example of displaying a matrix using the presentation elements of MathML. Browsers do not support MathML the same way, some do better than others. Generally speaking browsers that support HTML5 should support MathML to some extent. This post considers only the latest versions of Firefox and Microsoft Edge at present.

This page can be hosted on a web server(in this case on the local ISS, IIS Version 10.0.10586) on Windows 10 Pro)

Matrix Display with MathML


Matrix A
 
     
  A
  =
 
   
     
         x
         y
     

     
         z
         w
     

   

 

   




This is a very simple page but there are differences how the browsers display them. The MathML is highlighted in yellow in the HTML page.

Firefox 42
Firefox displays as shown here without any modification. This is the correct way of displaying a matrix.




Microsoft Edge 25

The HTML code used as is (with the