Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在R中为表中的testscores分配字母等级_R - Fatal编程技术网

在R中为表中的testscores分配字母等级

在R中为表中的testscores分配字母等级,r,R,试试这个: Error in rep(value, length.out = nrows) : attempt to replicate an object of type 'closure' set.seed(1)#用于可复制的示例 classlist这可能有助于将函数分配给classlist$Grade。要使代码正常工作,应首先创建函数myfunc Error in rep(value, length.out = nrows) : attempt to replicate an

试试这个:

Error in rep(value, length.out = nrows) : 
  attempt to replicate an object of type 'closure'
set.seed(1)#用于可复制的示例

classlist这可能有助于将函数分配给
classlist$Grade
。要使代码正常工作,应首先创建函数
myfunc
Error in rep(value, length.out = nrows) : 
  attempt to replicate an object of type 'closure'
set.seed(1)    # for reproducible example
classlist        <- data.frame(scores=runif(35,60,100))
classlist$grades <- cut(classlist$scores, 
                        breaks=c(0,seq(75,100,by=5)),
                        labels=c("C","B-","B","B+","A-","A"))
head(classlist,10)
#      scores grades
# 1  70.62035      C
# 2  74.88496      C
# 3  82.91413      B
# 4  96.32831      A
# 5  68.06728      C
# 6  95.93559      A
# 7  97.78701      A
# 8  86.43191     B+
# 9  85.16456     B+
# 10 62.47145      C