Operations on Matrices and Data Frames - English
- Questions posted on Forums
- R Tutorials - English
-
assignment
i am not able to do the second question of the assignment please help me with the command.
12-13M 10-20SMay 15, 2025, 12:44 a.m. kinshuk02
-
File captaincy is not opening
source('C:/Users/Joohi/Desktop/My Project/Matrices/myMatrix.R', echo=TRUE)> # Clear R workspace> rm(list = ls() ) > # Declare a variable to read and store the data frame > captaincy = read.csv("CaptaincyData.csv")Error in file(file, "rt") : cannot open the connectionIn addition: Warning message:In file(file, "rt") : cannot open file 'CaptaincyData.csv': No such file or directory> # Clear R workspace> rm(list = ls() ) > > # Declare a variable to read and store the data frame > captaincy = read.csv("CaptaincyData.csv")Error in file(file, "rt") : cannot open the connectionIn addition: Warning message:In file(file, "rt") : cannot open file 'CaptaincyData.csv': No such file or directory> > # View the stored data frame > View(captaincy)Error in View : object 'captaincy' not found> CaptaincyData <- read.csv("C:/Users/Joohi/Desktop/My Project/Matrices/CaptaincyData.csv")> View(CaptaincyData)> # Clear R workspace> rm(list = ls() ) > > # Declare a variable to read and store the data frame > captaincy = read.csv("CaptaincyData.csv")Error in file(file, "rt") : cannot open the connectionIn addition: Warning message:In file(file, "rt") : cannot open file 'CaptaincyData.csv': No such file or directory> > # View the stored data frame > View(captaincy)Error in View : object 'captaincy' not found> # Clear R workspace> rm(list = ls() ) > > # Declare a variable to read and store the data frame > captaincy = read.csv("CaptaincyData.csv")Error in file(file, "rt") : cannot open the connectionIn addition: Warning message:In file(file, "rt") : cannot open file 'CaptaincyData.csv': No such file or directory> > # View the stored data frame > View(captaincy)Error in View : object 'captaincy' not found> # Declare a variable to read and store the data frame > captaincy = read.csv("CaptaincyData.csv")Error in file(file, "rt") : cannot open the connectionIn addition: Warning message:In file(file, "rt") : cannot open file 'CaptaincyData.csv': No such file or directory> > # View the stored data frame > View(captaincy)Error in View : object 'captaincy' not found>
01-02M 10-20SMay 15, 2025, 4:51 a.m. Joohi
-
Remove of specific row
Sir I like to ask what is the command for removing the added row in the matrixes as by mistake add command two times because of which I made the entry of Kohli two times. As it is out of the topic but sir I am facing this problems. Kindly guide me to know the command for removable of specific row.
09-10M 40-50SMay 15, 2025, 4:09 p.m. manishakdey@gmail.com
-
Finding sum of all elements in matrixA using inbuilt functions
startTime <- Sys.time() totalsum <- 0 for (i in 1:3) { for (j in 1:3) { totalsum <- totalsum+matrixA[i,j] } } print(totalsum)[1] 237endTime <- Sys.time()endTime- startTimeTime difference of 0.008000851 secs startTime <- Sys.time() sum(matrixA)[1] 237 endTime <- Sys.time() endTime- startTimeTime difference of 0 secsSir the above time difference is ok
08-09M 20-30SMay 15, 2025, 8:45 a.m. Alamu
-
Creating New Row
inputcaptaincy <- rbind(captaincy, data.frame(names= "Kohli", y=2016, played=30, won=20, lost=9, victory=20/30 ) )View(captaincy)OutputError in match.names(clabs, names(xi)) : names do not match previous names
10-11M 10-20SMay 15, 2025, 11:32 a.m. kalaibalakannan@gmail.com
-
Operations on Matrices and Data Frames
[,1] [,2][1,] 9 10[2,] 11 12[3,] 13 14[4,] 15 16 valuesC[1,] 9 10 17[2,] 11 12 18[3,] 13 14 19[4,] 15 16 20 how to change the row header to 1, 2, 3. in the above output row header is not appearing for two columns. kindly guide.
11-12M 40-50SMay 15, 2025, 12:11 p.m. angaiaruvi@gmail.com
-
Usage of rbind function
1. Can a row be inserted in the middle of data frame using rbind function?2. Can multiple rows be inserted at once using rbind function in data frame?3. Can a data be inserted at once in multiple data frames using rbind function?
10-11M 10-20SMay 15, 2025, 1:25 p.m. annieahuja89@gmail.com
-
Adding Multiple Data Frame
Firstly, I performed rbind to add new data row.Then, the csv file is updated by doing write.csv operation.By running the R script file again, new column (X) exists in the dataframe and that makes number of columns of arguments do not match problem for further data frame addition.How to solve it?I also attached my code.captaincy=read.csv("CaptaincyData.csv")captaincy <- rbind(captaincy,data.frame(names="Dravid",Y=2008,played=25,won=8,lost=6,victory=0.32))write.csv(captaincy,"CaptaincyData.csv")In adding new column using cbind by running R script file repeatedly, new column exists. (in this case: just only new column exists)
08-09M 40-50SMay 15, 2025, 2:53 a.m. EKW
-
Regarding Matrix Operations
Apart from binding rows and cols using rbind and cbind , it would be more helpful, if the video suggests edit and delete operations on a matrix.
11-12M 50-60SMay 14, 2025, 6:40 a.m. sureshk1704@gmail.com
-
1
Overview of R and RStudio -
2
Installing R and RStudio on Linux -
3
Installing R and RStudio on Windows -
4
Introduction to basics of R -
5
Introduction to Data Frames in R -
6
Introduction to RStudio -
7
Introduction to R script -
8
Working directories in RStudio -
9
Indexing and Slicing Data Frames -
10
Creating Matrices using Data Frames -
Operations on Matrices and Data Frames -
12
Merging and Importing Data -
13
Data types and Factors -
14
Lists and its Operations -
15
Plotting Histograms and Pie Chart -
16
Plotting Bar Charts and Scatter Plot -
17
Introduction to ggplot2 -
18
Aesthetic Mapping in ggplot2 -
19
Data Manipulation using dplyr Package -
20
More Functions in dplyr Package -
21
Pipe Operator -
22
Conditional Statements -
23
Functions in R
Questions posted on ST Forums:
Outline:
How to find the inverse of a matrix How to calculate the sum of elements in a matrix using for loop How to calculate the sum of elements in a matrix using the sum function How to calculate the time elapsed in an operation How to find out the sum of rows of a matrix How to find out the sum of columns of a matrix How to add a new column or row to an existing data-frame How to use cbind and rbind function