Roth IRA Contribution - Actual and Excess Contribution

I would like to ask for some guidance on the following scenario:

 

1. I didn't know what my total income was going to be and thought that I would contribute less than the projected limit.  The amount I actually contributed was $2792

2. Anticipate that the earning from the actual contributions is approximately $562 (long- and short-term capital gains and dividends).

3. Based on actual income, the total allowable ROTH IRA contributions was $960.

 

If I withdraw the actual contribution, can I leave the earning and treat that as my ROTH IRA contribution? 

 

I am under the assumption that the actual contribution can be withdrawn without any tax and penalty because it is post tax contribution.