i am not able to do the second question of the assignment please help me with the command.
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)
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>
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.
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
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
[,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.
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?
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.
16121 visits
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
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
Show video info
Pre-requisite