You are getting that error message because you haven't defined a data frame called "matrix" but you are making reference to it, see this example:
Week <- c(1:7)
Sales <- c(39,44,40,45,38,43,99)
matrix <- data.frame(Week, Sales)
matrix$Smooth <- smooth(matrix$Sales)
matrix
#> Week Sales Smooth
#> 1 1 39 40
#> 2 2 44 40
#> 3 3 40 40
#> 4 4 45 43
#> 5 5 38 43
#> 6 6 43 43
#> 7 7 99 43
Created on 2019-11-21 by the reprex package (v0.3.0.9000)