Error: $ operator not defined for this S4 class

空扰寡人 提交于 2021-01-27 04:41:30

问题


I'm trying to make a formula and I got the error:

$ operator not defined for this S4 class with R.

First of all, what is a S4 class? What am I doing wrong?

Following the code:

as.formula("ctree(d$sex ~ d$ahe , data = d)")

If you want to reproduce it, the dataset (CSV file) d is available here.


回答1:


You are giving as.formula the wrong input here. Only d$sex ~ d$ahe should be a formula, so:

ctree(as.formula("d$sex ~ d$ahe"))

Or:

ctree(as.formula("sex ~ ahe"), data = d)


来源:https://stackoverflow.com/questions/36737628/error-operator-not-defined-for-this-s4-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!