[latex for the question]

First, I will define my vectors:

b <- c(2,1,2,1)

w1 <- c(1,2,0,2)
w2 <- c(1,0,3,1)
w3 <- c(0,1,0,2)
w4 <- c(1,1,2,0)

For my operations, it makes sense to consider my subspace W as a single matrix.

W = matrix(c(w1,w2,w3,w4), ncol=4)

W
##      [,1] [,2] [,3] [,4]
## [1,]    1    1    0    1
## [2,]    2    0    1    1
## [3,]    0    3    0    2
## [4,]    2    1    2    0

Next, I will check for linear independence by confirming the determinant of matrix W is not 0.

det(W) != 0
## [1] TRUE

Now, I can determine if b is in the subspace W by solving the equation Wx = b. If this equation returns a solution for x, b is indeed in the subspace W.

solve(W,b)
## [1]  1.5  1.0 -1.5 -0.5

Since the solve function returned a vector x, b is in the subspace W.