0

I am trying to partition my data set(my.data2) to train and test, but when I run the below script, I got an error show below:

ind<-sample(2,nrow(my.data2),replace = TRUE, prob=c(0.8,0.2))
train <- my.data2[ind=1, ]
test <- my.data2[ind=2,]

I will get the following error:

Error in `[.tbl_df`(my.data2, ind = 1, ) : unused argument (ind = 1)

Appreciate for any help!

Lucy
  • 1
  • 1

1 Answers1

1

you need to use== instead of =.

I would also suggest to look into this. It will give you a nice idea how you can split data into a train-to-test ratio.

  • Thank you so much! This works, I am a rookie level beginner of r, appreciate the help! – Lucy Jul 15 '18 at 21:29