1

Suppose we take the sample data set in this we have Purchased column as dependent factor. So if we need to perform sample.split(), it it necessary to perform sample.split on Purchased column itself??

library(caTools)

split = sample.split(dataset$Purchased, SplitRatio = 0.8)

or we can do any other column like

split = sample.split(dataset$Age, SplitRatio = 0.8) 

or on the entire data set as a whole ?

split = sample.split(dataset, SplitRatio = 0.8) 
zx8754
  • 52,746
  • 12
  • 114
  • 209
Tathagata
  • 11
  • 2
  • Paste your data as text, read about reproducible example https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – zx8754 Apr 13 '21 at 07:36
  • The function expects a vector, not a whole data.frame, so your last version may not be appropriate. – Roman Luštrik Apr 13 '21 at 08:13
  • Thanks @RomanLuštrik what about taking any other vector other than dependent factor? why do we need to take dependent vector only ? – Tathagata Apr 13 '21 at 09:49

0 Answers0