gpt4 book ai didi

r - 初始化 data.frames()

转载 作者:行者123 更新时间:2023-12-02 02:45:24 26 4
gpt4 key购买 nike

有没有快速的方法来初始化空数据框?如果你知道尺寸是多少?例如:

假设我想要一个有 100 行和 10 行的空白数据框:

x <- data.frame(1:100,2,3,4,5,6,7,8,9,10) 
dim(x) ## that's right

但是假设我想要 300 列之类的东西?如何快速初始化 data.frame 中的列?

x <- data.frame(1:100,2,3,4,5 ....) ## *cries*

最佳答案

> df <- data.frame(matrix(ncol = 300, nrow = 100))
> dim(df)
[1] 100 300

关于r - 初始化 data.frames(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4868903/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com