r - 'list' 对象不能被强制输入'integer' -- WRS2 包
问题描述
尝试使用 WRS2 包的功能时遇到以下错误。
sequence.default(piece, ...) 中的错误:不能强制“list”对象键入“integer”
下面是代码。Percentile_rank、grade_level 和 books_quantile 的数据类型是数值数据。Percentile rank 的值是 1-99,grade_level 是 1-10,books_quantile 是 1-3。每个观察结果都反映了一个学生的成绩、他们的考试成绩的百分位排名以及他们收到的书籍数量的四分位数。
library(WRS2)
pbad2way(percentile_rank~ grade_level + books_quantile + grade_level*books_quantile,
data = read)
数据框“读取”的快照如下(我删除了一些敏感/不相关的变量)
tibble [20,903 x 21] (S3: tbl_df/tbl/data.frame)
$ id : chr [1:20903] "4886656" "4648093" "4544642" "4487743" ...
$ school_year_key : chr [1:20903] "2019" "2019" "2019" "2019" ...
$ grade_key : chr [1:20903] "736" "738" "738" "738" ...
$ grade_level : Factor w/ 10 levels "1","2","3","4",..: 1 3 3 3 3 3 3 3 3 4 ...
$ percentile_rank : num [1:20903] 43 97 84 23 27 5 84 6 1 21 ...
$ books_count : num [1:20903] 55 46 43 56 57 55 49 42 51 57 ...
$ discipline : chr [1:20903] "Reading" "Reading" "Reading" "Reading" ...
$ books_quantile : Factor w/ 3 levels "1","2","3": 2 2 2 3 3 2 2 2 2 3 ...
当我在错误后使用 traceback() 时,它显示如下:
8: sequence.default(piece, ...)
7: .fun(piece, ...)
6: (function (i)
{
piece <- pieces[[i]]
if (.inform) {
res <- try(.fun(piece, ...))
if (inherits(res, "try-error")) {
piece <- paste(utils::capture.output(print(piece)),
collapse = "\n")
stop("with piece ", i, ": \n", piece, call. = FALSE)
}
}
else {
res <- .fun(piece, ...)
}
progress$step()
res
})(10L)
5: loop_apply(n, do.ply)
4: llply(.data = pieces, .fun = .fun, ..., .progress = .progress,
.inform = .inform, .parallel = .parallel, .paropts = .paropts)
3: alply(nfac1, 1, sequence)
2: unlist(alply(nfac1, 1, sequence), use.names = FALSE)
1: pbad2way(percentile_rank ~ grade_level + books_quantile + grade_level *
books_quantile, data = read)
解决方案
推荐阅读
- ssh - Performance Testing of SFTP server using jMeter
- shell - 没有在 jenkinsfile 中获取变量值
- vue.js - VueJS 渲染函数 - 如何添加对另一个组件的引用?
- react-native - 如何将参数从其他 Stack React Native 传递给 Stack?
- jira - (Jira Software Server) IntelliJ 不会识别 atlassian 导入
- java - 如何将列拆分为列表并将其保存到新的 .csv 文件中
- c# - 从URL下载csv文件返回html页面c#
- flutter - 在颤动中点击容器内部
- git - Git状态:将某些文件显示为未修改,以便人们不会添加/提交它们
- scala - 在 spark scala 中读取大文件时数据丢失