【问题标题】:R - Warnings when creating empty data.frame w/ 21+ cols in JupyterR - 在 Jupyter 中创建具有/ 21+ 列的空数据框时的警告
【发布时间】:2020-07-24 14:02:05
【问题描述】:

当我创建一个包含 21 列的空 data.frame 时,我遇到了一个有趣的问题:

data.frame(x01 = numeric(),
           x02 = numeric(),
           x03 = numeric(),
           x04 = numeric(),
           x05 = numeric(), 
           x06 = numeric(),
           x07 = numeric(), 
           x08 = numeric(), 
           x09 = numeric(), 
           x10 = numeric(),
           x11 = numeric(), 
           x12 = numeric(),
           x13 = numeric(),
           x14 = numeric(), 
           x15 = numeric(),
           x16 = numeric(),
           x17 = numeric(),
           x18 = numeric(),
           x19 = numeric(),
           x20 = numeric(), 
           x21 = numeric())

我收到以下三个警告:

Warning message in cbind(parts$left, ellip_h, parts$right, deparse.level = 0L):
“number of rows of result is not a multiple of vector length (arg 2)”
Warning message in cbind(parts$left, ellip_h, parts$right, deparse.level = 0L):
“number of rows of result is not a multiple of vector length (arg 2)”
Warning message in cbind(parts$left, ellip_h, parts$right, deparse.level = 0L):
“number of rows of result is not a multiple of vector length (arg 2)”
Warning message in cbind(parts$left, ellip_h, parts$right, deparse.level = 0L):
“number of rows of result is not a multiple of vector length (arg 2)”

但没有问题,当我创建一个只有 20 列的 df 时,即省略最后一列。问题不是特定于 21 列,有更多列我仍然会收到警告。任何想法是什么问题以及如何解决它?

谢谢!

编辑:这只发生在 Jupyter 中(我在 Ubuntu 上运行 R 版本 3.6.3)

【问题讨论】:

  • 我没有收到该警告信息。重新启动 R 并重试。
  • 感谢您的检查!我也可以在终端中复制它。不过,这似乎是 Jupyter 的东西(我可以在 Jupyter 和 Jupyterhub 中复制它)

标签: r jupyter jupyter-irkernel


【解决方案1】:

试试怎么样

> data.frame(do.ca .... [TRUNCATED]
 [1] X1  X2  X3  X4  X5  X6  X7  X8  X9  X10 X11 X12 X13 X14 X15 X16 X17 X18 X19
[20] X20 X21
<0 rows> (or 0-length row.names)

【讨论】:

  • 感谢 Thomas 检查。尽管有警告,但上述方法确实有效。我主要是想了解发生了什么,而不是想办法解决它
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-02-14
  • 1970-01-01
相关资源
最近更新 更多