unable to calculate smoothing in R

Week Sales Forecast
1 39 39
2 44 39
3 40 40
4 45 40
5 38 41
6 43 40.4
7 39 40.92

this is my data in which I have calculated Smoothing value which is the forecast column. Any suggestion to calculate smoothing value in R. I was trying to calculate smoothing but I am unable to get the exact smoothing function.

Thanks in advance

There is the smooth() function.
In your case you could do:
matrix$Smooth <- smooth(matrix$Sales)

check ?smooth() for options

I am getting this error.

"Error in matrix$Sales : object of type 'closure' is not subsettable" while using

Week <- c(1:7)
Sales <- c(39,44,40,45,38,43,99)
library(smooth)
matrix$Smooth <- smooth(matrix$Sales)

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)