1
votes

while i was working got stuck here , i would appreciate if some one could assist me in resolving the issue, below is the code and error message for your reference.

library(caTools)
split_data <- sample.split(filter_data_1$spend, SplitRatio = 0.75)
split_data    
train_data <- subset(filter_data_1, split == TRUE)
test_data <- subset(filter_data_1, split == FALSE)

Error message :

test_data <- subset(filter_data_1, split = = FALSE)

Error:

unexpected '=' in "test_data <- subset(filter_data_1, split ==" test_data <- subset(filter_data_1, split == FALSE) Error in split == FALSE :
comparison (1) is possible only for atomic and list types

2
You've defined split_data, but then tried to use split. split happens to be a base R function, so that's the first object R will find when searching heirarchically for it. The error is telling you that [function] == [boolean] doesn't make sense. - rosscova
ohh thanks its working ..... - Radha Krishna

2 Answers

1
votes

This example works for me:

library(caTools)
library(MASS)
data(cats)
filter_data_1 <- cats
split_data <- sample.split(filter_data_1$Sex, SplitRatio = 0.75)
split_data    
train_data <- subset(filter_data_1, split_data == TRUE)
test_data <- subset(filter_data_1, split_data == FALSE)
0
votes

change split to 'split_data'

split_data = sample.split(filter_data_1$spend, SplitRatio = 0.75) train_data = subset(filter_data_1, split_data == TRUE) test_data = subset(filter_data_1, split_data == FALSE)

because in the first line the data set has already splitted.