building a regression set with a filter on one of the variables
Thats because the part of your formula: iris$Sepal.Length isn't filtered by Sepal Width, which is why the error is telling you that your variable lengths differ.
You need to filter both:
filtered <- iris[which(iris$Sepal.Width>=3.0),]
gg1 <- lm(filtered$Sepal.Length ~ filtered$Sepal.Width)
another option: lm(Sepal.Length ~ Sepal.Width, data = iris, subset = Sepal.Width >= 3.0)
more examples:
> ff <- lrm( IsChurn_Day7 ~ NumBasCurWinSmall + relevel(IsDepositor7Days,'0'), data = loc_dataD7,subset=NumBasCurWinSmall>=mean(NumBasCurWinSmall))
> print(ff)
# in this example the split is by precentiles:
ff <- lrm( Target ~ var1 + , data = dat ,subset=var1>=quantile(var1, 0.07) & var1<=quantile(var1, 0.09))