How to add an extra row to data frame in R

Here is a quick example of how to add extra rows to a data frame in R. I’m using the colMeans() function to calculate a new value I want to add. First loading the data into a data frame with Then doing a simple for loop going from one to ten. Lastly adding the extra row by using the nrow plus one.

df <-[1:2000, -1])
for (i in seq(1, 10, 1)) {
  df[(nrow(df) + 1),] = colMeans(id_mat[i:(i+199), -1])

Take a look at if you want to see how the colMeans() function works.