错误:未为此S4类定义$运算符 [英] Error: $ operator not defined for this S4 class

查看:420
本文介绍了错误:未为此S4类定义$运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制定公式,但出现错误:

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

未使用R为此S4类定义$运算符.

$ operator not defined for this S4 class with R.

首先,什么是S4类?我在做什么错了?

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

以下代码:

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

如果要复制它,则数据集(CSV文件) d

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

推荐答案

您在此处给 as.formula 输入错误.只有 d $ sex〜d $ ahe 应该是公式,所以:

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"))

或者:

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

这篇关于错误:未为此S4类定义$运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆