I would like help imposing restrictions on coefficients estimated in the regression model show below:

lm(Y ~ C + S, weights = W)

Y = stock returns

C = set of country membership binaries (1 or 0)

I = set of industry membership binaries (1 or 0)

W = market capitalization weights

C = set of country membership binaries (1 or 0)

I = set of industry membership binaries (1 or 0)

W = market capitalization weights

I'd like to estimate the country and industry effects as deviations from the capitalization weighted mean stock return. To do that, I need to impose two restrictions on the two sets of membership variable coefficients:

country coefficient betas * country weights = 0

industry coefficient betas * industry weights = 0

I can not seem to figure out how to implement these restrictions in R through the "lm" function. Does anyone know how?

Many thanks in advance!