I might be a little late, as I see the profile of Robert now has a baptism recorded, indicating James Allan and Agnes Scott as parents. Looking through the sources, and looking at the children, that is very likely correct. James is Robert and Jean's first son, and by Scotting patterns, the first son is named after the paternal grandfather. Likewise on the first daughter who is named after the material grandmother, and Robert and Jean's first daughter is Agnes. Assuming James and Agnes are the correct parents, you will find a marriage for them on 10th Nov 1799 in Tranent. If you follow James and Agnes, you find several children, whose baptisms are all found on Ancestry or FamilySearch. This leads to potential parents for James as James Allan and Euphemia Hunter. I hope this helps take you in a direction you haven't researched before. Cheers!