How to append rows to an R data frame

前端 未结 7 1549
太阳男子
太阳男子 2020-11-28 02:04

I have looked around StackOverflow, but I cannot find a solution specific to my problem, which involves appending rows to an R data frame.

I am initializing an empty

7条回答
  •  Happy的楠姐
    2020-11-28 02:41

    Lets take a vector 'point' which has numbers from 1 to 5

    point = c(1,2,3,4,5)

    if we want to append a number 6 anywhere inside the vector then below command may come handy

    i) Vectors

    new_var = append(point, 6 ,after = length(point))

    ii) columns of a table

    new_var = append(point, 6 ,after = length(mtcars$mpg))

    The command append takes three arguments:

    1. the vector/column to be modified.
    2. value to be included in the modified vector.
    3. a subscript, after which the values are to be appended.

    simple...!! Apologies in case of any...!

提交回复
热议问题