Statistics for an asymmetric raster-cell neighborhood are required.
The application is modelling direct solar insolation over year-long time steps while accounting for local shading effects of vegetation for an ecosystem energy balance. Consider for instance that at certain times of year, the sun will be directly overhead. In this case, direct rays from the sun will trace a right-to-left (east-to-west) path. In the image below, the black box is the target cell and the grey boxes are the daily path of the sun.
However, during other times of the year, the Earth tilts. When this happens, the direct rays entering the black square will be filtered through vegetation in a direction that is dependent on the season and this will have an important shading effect that must be considered. In the grid below, this shading effect induced by Earth's tilt is represented as grey squares with the black square again the target cell.
The focal() function from terra can be used to calculate statistics for matrices, and according to the documentation, rows and/or columns of 'NA' can be added to modulate what window is used to generate statistics from. I am not certain how to create such a window.
In addition, focal() results in a statistic for a center cell. What this means is that, in the second image above where seasonal shading effect occur, the black cell would (by focal) be shifted up one. This needs to be adjusted or accounted for.