Approximate definite integrals using Riemann sums
R, 69 65 63 57 bytes



function(a,b,n,k,f,w=(b-a)/n)sum(sapply(a+w*(1:n-k),f))*w


Try it online!

Takes k=FALSE for right-hand sums, although the TIO link now includes aliases for "left" and "right" for ease of use.

a+w*(1:n-k) generates appropriate left- or right-hand points.

Then sapply applies f to each element of the result, which we then sum up and multiply by the interval width (b-a)/n to yield the result. This last also neatly takes care of any sign issues we might have.