There is not much to it:
# Some data:
n <- 1000
x <- rnorm(n, mean = 7000, sd = 500)
y <- 50 + x*50 + rnorm(100)
weights <- 1:1000/1000
# Regression:
ols <- lm(y ~ x)
wls <- lm(y ~ x, weights = weights)
You simply specify the weightsweights
argument. R then applies the weights to each observation and the intercept.