You could write a script containing:
R CMD Sweaver "$1.Rnw"
pdflatex "$1.tex"
okular "$1.pdf"
If you name it foo.sh
, you could invoke it by saying:
sh foo.sh fn
or
bash foo.sh fn
and the shell would use the positional parameter that was passed in order to perform the variable substitution.