Reputation: 133
I have a dataframe with 140 rows and I'm splitting data randomly to test data and training data.
But while splitting the data using sample.split method in caTools library, I encountered an error.
Following is my code:
library(caTools)
set.seed(42)
features <- read.csv(file = './featur.csv', header = TRUE)
features
features$split = sample.split(features,SplitRatio = 0.8)
This is the error I get:
Error in `$<-.data.frame`(`*tmp*`, split, value = c(TRUE, FALSE, TRUE, :
replacement has 18 rows, data has 140
Can anyone give a clue on what's causing this error and how I can fix it?
Upvotes: 1
Views: 248
Reputation: 133
Apparently user @RuiBarrads from the comment told me that the output of sample.split shouldn't be a column. I changed that, and it fixed it.
Upvotes: 1