library(tree)
library(ISLR)
data("Carseats")
High<-ifelse(Carseats$Sales<=8,'No','Yes')
Carseats<-data.frame(Carseats,High)
tree.Carseats<-tree(as.factor(High)~.-Sales, data = Carseats)
summary(tree.Carseats)
plot(tree.Carseats)
text(tree.Carseats,pretty=0)
set.seed(1)
train=sample(1:nrow(Carseats),200)
I am writing to ask about the code train=sample(1:nrow(Carseats),200).
The result of this code simply show the data and I cannot use View(train) to see the data set.
IMO,I think for the sample, we are going to choose the row of the dataset data(Carseats), each element should contain some labels such as Sales, Income...
Maybe I am confused with the theoretical ideas behind.