Don't recalculate quantile(X,0.5) each and every time: it never changes, calculate it once and reuse the stored value.
Use vectorized operations, knowing that comparisons and assignments can happen a whole vector at a time. I suggest that you can reduce that to:
X <- rt(1250,5)
eps <- rt(1250,5)
med <- quantile(X, 0.5)
Y <- ifelse(X > med, 1, 1.5) * X + eps
A quick walk-through of vectorized operations demonstrated here:
set.seed(42)
X <- rt(10, 5)
eps <- rt(10, 5)
med <- quantile(X, 0.5)
X
# [1] 1.9151 0.0878 -0.0773 -0.0618 -0.0480 5.0230 1.0924 0.8423 1.5165
# [10] -0.2601
eps
# [1] 0.712 -1.048 2.233 -0.737 -1.273 -0.890 0.395 -1.828 -0.601 -0.392
med
# 50%
# 0.465
If we compare a vector with a scalar (or a vector with the same-length vector), then we get a vector of logical/boolean:
X > med
# [1] TRUE FALSE FALSE FALSE FALSE TRUE TRUE TRUE TRUE FALSE
From this, ifelse is a vectorized conditional. While if (...) {...} else {...} can deal with a single length-1 logical at a time, ifelse works on a vector at a time. For instance:
ifelse(c(T, F, F, T), 1:4, 11:14)
# [1] 1 12 13 4
Back to the example, we continue with ifelse and add math operations, which also work just as well on a vector as a scalar.
ifelse(X > med, 1, 1.5)
# [1] 1.0 1.5 1.5 1.5 1.5 1.0 1.0 1.0 1.0 1.5
ifelse(X > med, 1, 1.5) * X
# [1] 1.9151 0.1318 -0.1160 -0.0926 -0.0720 5.0230 1.0924 0.8423 1.5165
# [10] -0.3902