You could use
This is a Bioconductor package and is easy to use with R.
You could also use the
This is also a Bioconductor package and easy to use.
Go through the manuals and try to follow steps with the given examples.
You can also use MSigDB gene set data with the gene set tools in the limma package (also found in edgeR package if you are analyzing NGS data using GLMs). Tools like
romer(), etc., all can use gene sets, like those defined in MSigDB. You can download MSigDB gene sets in an R friendly format from the limma/edgeR developer's website here. Take a look at
help("10.GeneSetTests") in the limma documentation. Some examples are shown also in the limma and edgeR user's guide.