How to initialize empty data frame (lot of columns at the same time) in R

前端 未结 2 1662
难免孤独
难免孤独 2020-11-29 06:25

I found how to initialize an empty data frame with 3 or 4 dimensions. It\'s like

df <- data.frame(Date=as.Date(character()),
             File=character(         


        
2条回答
  •  隐瞒了意图╮
    2020-11-29 07:09

    Maybe this -

    df <- data.frame(matrix(ncol = 10000, nrow = 0))
    colnames(df) <- paste0("hello", c(1:10000))
    

    And @joran's suggestion - df <- setNames(data.frame(matrix(ncol = 10000, nrow = 0)),paste0("hello", c(1:10000)))

提交回复
热议问题