0
`setwd("C:/Users/rsiky/Documents/summer2021/week2/cvs_files")
 credit <- read.csv(file="CreditApproval.csv", head=TRUE, sep=",", 
 stringsAsFactors = TRUE)
 # Review Structure of dataset
 str(credit)

# Load libraries
# Discretize
summary(credit$A2); credit$A2<-discretize(credit$A2, "frequency", breaks=6); 
summary(credit$A2)
summary(credit$A3); credit$A3<-discretize(credit$A3, "frequency", breaks=6); 
summary(credit$A3)
summary(credit$A8); credit$A8<-discretize(credit$A8, "frequency", breaks=6); 
summary(credit$A8)
summary(credit$A11); credit$A11<-discretize(credit$A11, "interval", 
breaks=6); summary(credit$A11)
summary(credit$A14); credit$A14<-discretize(credit$A14, "interval", 
breaks=6); summary(credit$A14)
summary(credit$A15); credit$A15<-discretize(credit$A15, "interval", 
breaks=6); summary(credit$A15)
credit$A3<-factor(credit$A3)
summary(credit$A3)
set.seed(1234)
ind <- sample(2, nrow(credit), replace = TRUE, prob = c(0.7, 0.3))
train.data <- credit[ind == 1, ]
test.data <- credit[ind == 2, ]
myFormula<-A3~.
credit__ctree<-ctree(myFormula, data = train.data)
print(credit_ctree)`

When I run the print command I get the following error:

Error in h(simpleError(msg, call)) : error in evaluating the argument 'x' in selecting a method for function 'print': object 'credit_ctree' not found

How do I resolve this error?

Gowachin
  • 1,251
  • 2
  • 9
  • 17
GabJosh
  • 37
  • 3
  • Hi, could you provide a small example of what `train.data` looks like so we can reproduce this ? See https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Gowachin Jun 15 '21 at 16:47
  • The train.data is generated from data in a csv file. Is there a way to attach the file? – GabJosh Jun 15 '21 at 16:57
  • A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,class b,30.83,0,u,g,w,v,1.25,t,t,1,f,g,202,0,+ a,58.67,4.46,u,g,q,h,3.04,t,t,6,f,g,43,560,+ a,24.5,0.5,u,g,q,h,1.5,t,f,0,f,g,280,824,+ b,27.83,1.54,u,g,w,v,3.75,t,t,5,t,g,100,3,+ b,20.17,5.625,u,g,w,v,1.71,t,f,0,f,s,120,0,+ b,32.08,4,u,g,m,v,2.5,t,f,0,t,g,360,0,+ b,33.17,1.04,u,g,r,h,6.5,t,f,0,t,g,164,31285,+ a,22.92,11.585,u,g,cc,v,0.04,t,f,0,f,g,80,1349,+ b,54.42,0.5,y,p,k,h,3.96,t,f,0,f,g,180,314,+ b,42.5,4.915,y,p,w,v,3.165,t,f,0,t,g,52,1442,+ b,22.08,0.83,u,g,c,h,2.165,f,f,0,t,g,128,0,+ – GabJosh Jun 15 '21 at 17:05
  • here is some of the data – GabJosh Jun 15 '21 at 17:05
  • There is tutorial in the link I provided for importing dataset in a practical way, like `dput()`. – Gowachin Jun 15 '21 at 19:12

1 Answers1

0

The problem was a typo in the second to last line

credit__ctree<-ctree(myFormula, data = train.data) print(credit_ctree)`

as you can see there is an extra underscore I had credit__ctree and it should have been credit_ctree

GabJosh
  • 37
  • 3