‘list’ object cannot be coerced to type ‘integer’ — WRS2 package

I come across the below error when trying to use a function of WRS2 package.

Error in sequence.default(piece, ...) : 'list' object cannot be coerced to type 'integer'

Below is the code. Percentile_rank, grade_level, and books_quantile's data types are numeric data. Percentile rank's value is from 1-99, grade_level from 1-10, and books_quantile from 1-3. And each observation reflects one student's grade, their test score's percentile rank, and the quartile of number of books they received.

library(WRS2)
pbad2way(percentile_rank~ grade_level + books_quantile + grade_level*books_quantile,
         data = read) 

A snapshot of data frame "read" is as below (I removed some variables that are sensitive/not relevant)

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 ...



Read more here: https://stackoverflow.com/questions/66994409/list-object-cannot-be-coerced-to-type-integer-wrs2-package

Content Attribution

This content was originally published by Ann Ng at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: