I am trying to display a series of plots in R based on a condition with a variable taking a sequence of values something like simple clustering. I have data frame with numerical columns X and Y respectively. There is also a Z column with text values (categorical variable). I am trying the following code but it doesn't work. The code works fine if instead I use numerical values for i and j, example i=50 and j=100.
my data frame: new.data, columns: X, Y, Z
j=0
for(i in seq(0, 500, by = 50)){
j=i+50
PlotData <- new.data[(new.data$X <j) & (new.data$X >i),]
ggplot (PlotData, aes(X, Y, color = Z)) + geom_point()
}