在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