You now have the one enquiry at two forum sites. This is not a good idea. It is inefficient because people who would respond to your enquiry need one site only, the better to pool information.
Assuming that you know your ancestor to be born in Ayrshire, this (Ayrshire) site would be better than using the Common Room.
I am assuming that you are researching the origins of your great great grandfather, James GRAY?
You need to say where are you reading about the death of Andrew, at sea, 1854.
"..my GGG Grandfather Andrew Gray was born in Ayrshire in 1822 . he had a son James and was married to Margaret Robb?."
You are using a question mark here. What are you uncertain about.........the name of his wife........the name of his son......was there a marriage?
If you are researching the origins of your great great grandfather James GRAY, start with the earliest evidence you have of him, which is probably a marriage record.
Do you see these people in the 1851 census?