【发布时间】:2020-09-07 17:15:22
【问题描述】:
我在 R 中使用了一个小代码:
dat$colour<-rep(rainbow(4)) #you get a warning if you not have a multiple of 4 records, but that is ok.
dat 由七行组成。我已经包含rep() 以确保即使七不是四的倍数也可以重复颜色。但是,我仍然收到以下错误:
Error in set(x, j = name, value = value) : Supplied 4 items to be assigned to 7 items of column 'colour'. If you wish to 'recycle' the RHS please use rep() to make this intent clear to readers of your code.
复制:
dat <- data.table('Year' = c(2010, 2011, 2012, 2013, 2014, 2015, 2016))
dat$colour<-rep(rainbow(4))
我真的很重视帮助,脚本是自动化的,但现在给了我这个错误。 我刚换了一台新电脑,问题可能出在这个或那个版本不正确。
谢谢!
【问题讨论】: