I would like to download all the gene pathways and genes of each pathway. Preferably, gene length of each gene as well. It would be a lot more convenient if there is an R package.
Try using KEGG REST.
http://rest.kegg.jp/link/pathway/hsa ## list of all genes and pathways in Humans
If you're working with BioCyc pathways you can use their REST-API for batch-downloading all genes for their pathways. You can run a wide range of queries including BioVelo-queries for all genes/compounds in a specified pathway, all pathways in organism etc. A query for all the pathways in B. subtilis would look like:
Where you get an XML with the Cyc-IDs for the pathways which can be used to search for the genes. A query for all genes in the Arginine synthesis pathway in B. subtilis would then look like:
Which returns an XML with information regarding the genes, start and end positions including (i.e. gene length). Since I don't work very much in R I don't know if there exists an R-package. But it is very straightforward to write Python scripts for downloading and XML-parsing.