<jupyter_start><jupyter_text>Matrix<jupyter_code>matrix1<-matrix(c(11, 13, 15, 12, 14, 16),nrow =2, ncol =3, byrow = TRUE)  
matrix1  
# Defining the column and row names.  
row_names = c("row1", "row2", "row3", "row4")  
col_names = c("col1", "col2", "col3")  
#Creating matrix   
R <- matrix(c(5:16), nrow = 4, byrow = TRUE, dimnames = list(row_names, col_names))  
print(R)  
  
#Accessing element present on 3rd row and 2nd column  
print(R[3,2])  
  
#Accessing element present in 3rd row  
print(R[3,])  
  
#Accessing element present in 2nd column  
print(R[,2])  
# Defining the column and row names.  
row_names = c("row1", "row2", "row3", "row4")  
ccol_names = c("col1", "col2", "col3")  
  
R <- matrix(c(5:16), nrow = 4, byrow = TRUE, dimnames = list(row_names, col_names))  
print(R)  
  
#Assigning value 20 to the element at 3d roe and 2nd column  
R[3,2]<-20  
print(R)  
# Defining the column and row names.  
row_names = c("row1", "row2", "row3", "row4")  
ccol_names = c("col1", "col2", "col3")  
  
R <- matrix(c(5:16), nrow = 4, byrow = TRUE, dimnames = list(row_names, col_names))  
print(R)  
  
#Adding row  
rbind(R,c(17,18,19))  
  
#Adding column  
cbind(R,c(17,18,19,20))  
  
#transpose of the matrix using the t() function:  
t(R)  
  
#Modifying the dimension of the matrix using the dim() function  
dim(R)<-c(1,12)  
print(R)  
R <- matrix(c(5:16), nrow = 4,ncol=3)  
S <- matrix(c(1:12), nrow = 4,ncol=3)  
  
#Addition  
sum<-R+S  
print(sum)  
  
#Subtraction  
sub<-R-S  
print(sub)  
  
#Multiplication  
mul<-R*S  
print(mul)  
  
#Multiplication by constant  
mul1<-R*12  
print(mul1)  
  
#Division  
div<-R/S  
print(div)<jupyter_output>[,1] [,2] [,3]
[1,]    6   14   22
[2,]    8   16   24
[3,]   10   18   26
[4,]   12   20   28
     [,1] [,2] [,3]
[1,]    4    4    4
[2,]    4    4    4
[3,]    4    4    4
[4,]    4    4    4
     [,1] [,2] [,3]
[1,]    5   45  117
[2,]   12   60  140
[3,]   21   77  165
[4,]   32   96  192
     [,1] [,2] [,3]
[1,]   60  108  156
[2,]   72  120  168
[3,]   84  132  180
[4,]   96  144  192
         [,1]     [,2]     [,3]
[1,] 5.000000 1.800000 1.444444
[2,] 3.000000 1.666667 1.400000
[3,] 2.333333 1.571429 1.363636
[4,] 2.000000 1.500000 1.333333
{'fraction_non_alphanumeric': 0.17502238137869292, 'fraction_numerical': 0.1378692927484333, 'mean_word_length': 2.6639344262295084, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '524608', 'license': 'MIT', 'n_tokens_mistral': 1198, 'n_tokens_neox': 1028, 'n_words': 273, 'path': 'R-programming/Data structure/matrix.ipynb', 'repo_name': 'Nikhil-Wani/Hackerrank-Codes', 'size': '2234'}