Answers here are incomplete. A conversion from rental property to residence has multiple steps to calculate the correct taxation of the transaction. Read professional analysis previously cited or pay for professional help. Tax software is another alternative. You are responsible for your return. Code, regulations, case law is all the IRS wants to hear about support for the tax treatment on the return
Deferral of a gain is a different more complicated issue.
A special rule enacted in 2008 requires the proration of gain on the sale of a personal residence that was initially used other than as a personal residence. See link below
Tax Issues When Converting a Rental to Your Personal Residence | Professional Tax Services