R (rStudio): 查看错误 'names' 属性 [4] 必须与字符向量的向量 [1] 长度相同

R (rStudio): View error 'names' attribute [4] must be the same length as the vector [1] for character vector

最近经常出现这种情况,不知如何解决。 N.B。我正在使用 rStudio v0.99.893

我从 data.table 创建了一个字符向量,然后我尝试查看它,并收到上述错误: Error in View : 'names' attribute [4] must be the same length as the vector [1]

原始 DT 有 12 个变量的约 10,000 个观察值,这里是一个捕获所有 类:

的子集
> head(DT, 3)
    HQ       URL      type  ID1 ID2  completion  date_first
1: imag image-welcome basic 444 24   0.1111111   2016-01-04 14:55:57 
2: imag image-welcome basic 329 12   0.2222222   2016-03-15 11:37:21
3: imag image-confirm int   101 99   0.1111111   2016-01-06 20:55:07

as.character(sapply(DT, class))
[1] "character"     "character"    "character"    "integer"    
[5] "integer"    "numeric"    "c(\"POSIXct\", \"POSIXt\")"

DT 我为感兴趣的子集(仅 'imag' HQ)创建了 URL 的唯一值的字符向量:

URL.unique <- unique(DT[HQ == "imag", URL])
> class(URL.unique)
[1] "character"

> names(URL.unique)
NULL

> View(URL.unique)
Error in View : 'names' attribute [4] must be the same length as the vector [1]

> length(URL.unique)
[1] 262

在控制台中打印 URL.unique 工作正常,通过 write.table() 导出它也是如此,但令人讨厌的是我无法查看它。

除非上述内容有隐含的错误,否则我将求助于重新安装 rStudio。我已经尝试过退出并重新启动,以防出现一些问题,因为我倾向于在几天内在我的计算机上打开多个项目。

如有任何帮助,我们将不胜感激!

正如@Jonathan 所指出的,目前已将此提交给 RStudio 进行调查。可以确认重新安装和其他措施 没有 解决仍然存在的问题。如果它被复制并作为错误归档,我会请求@Jonathan 在此处提供详细信息以供其他人参考。

View(data.frame(u = URL.unique)) 的解决方法可以在感兴趣的数据对象上启动查看器(感谢@Frank)

我正在使用 View(as.matrix(df$col_name)),它似乎运行良好。