I want to implement ID based encryption using the RSA encryption algorithm but how can I edit the algorithm for IDs.
Simple answer: you cannot. Identity-based encryption is an advanced cryptographic primitive, you cannot simply take any existing encryption algorithm and make it identity-based with simple modifications. There exists several constructions of IBE, but they all strongly differ from the standard RSA algorithm. You can find more information on the wikipedia page. There are several schemes that could suit you, such as Cocks QRA-based IBE (link on the wikipedia page) if you really want something that works in RSA groups (but note that it is not based on RSA). More classically, you could consider using a pairing-based IBE scheme, such as the famous scheme of Boneh and Franklin. Further details and links to implementations of IBEs can be found here.