Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: $ operator not defined for this S4 class

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.

like image 360
Reinaldo Maciel Avatar asked Apr 20 '16 08:04

Reinaldo Maciel


1 Answers

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)
like image 191
slamballais Avatar answered Oct 24 '22 12:10

slamballais