R define dimensions of empty data frame

前端 未结 11 1162
清歌不尽
清歌不尽 2020-12-12 21:34

I am trying to collect some data from multiple subsets of a data set and need to create a data frame to collect the results. My problem is don\'t know how to create an empt

11条回答
  •  难免孤独
    2020-12-12 22:21

    Just create a data frame of empty vectors:

    collect1 <- data.frame(id = character(0), max1 = numeric(0), max2 = numeric(0))
    

    But if you know how many rows you're going to have in advance, you should just create the data frame with that many rows to start with.

提交回复
热议问题