This question has many ways to answer, but here is a very, very basic answer.
This is one of the examples provided in the help files for ARIMA in the forecast package:
fit <- arima(WWWusage,order=c(3,1,0))
Suppose you want the original series in red and the fitted series in blue:
You can try out this commands and check the output!