Well, there are times when it was cheaper to grow it myself and times when I am better off buying from the farmer's market.
What was the difference?
What I was able to grow easily on my land
Food prices for what I want
The time required
The way I grew the plants
Availability locally of specific foods
Healthiness of home grown vs commercial grown foods
Examples
WIN: Rhubarb in the store is expensive. I grow it easily under some trees in the back yard. All it requires is an occasional watering. This is a no brainer.
LOSE: The soil in Colorado is hard and compact. It takes a lot of work to loosen up the soil deep enough to allow the carrots to grow. I did all the work, planted carrots, and between the bugs, the soil re-compacting, and crummy weather, I got 4 carrots. 4. Pathetic. These are not worth my time.
WIN: I got a grape vine on clearance at a home & garden store that was going out of business. I paid 3 or 4 dollars for it. I planted it and watered it. No other special attention was paid to the vine. It started giving me grapes after 2 years. It is now huge 7 years later. Last year I harvested over 50lbs of grapes from one vine. (We actually have 2...the other one was also a clearance, charlie brown plant.) Since it only required a bit of trimming here and there AND it now covers a shade arbor, this was a big win.
WIN and LOSE: Beans. I got a few dragon tongue bean seeds from a seed swap. I planted them in an experimental garden that uses pond water irrigation in trays. They went NUTS. Lots of tasty beans. I ate most of them myself

(but my ducks also helped. If they saw me anywhere near the beans they started begging. We liked them a LOT!) Now, for my other bean patch...I planted it in the ground in the front yard. Between the pill bugs, the earwigs, and the slugs, I got 2 beans from 6 plants. This spring I will be planting ALL my beans in the pond irrigation system using trays and ditch the bean patch in bugland.
LOSE: Zucchini. I have a small growing area. Zucchini vines take up a LOT of space. Since I can get them 4/$1 at the farmer's market it really doesn't make sense for me to waste the space I could be using for other things I CAN'T get cheaply like heirloom tomatoes.
NEW EXPERIMENT: I am planting ground cherries this year. You can't buy them in the stores. Since a pack of seeds is $3, I think it is worth a try. If I can get a halfway descent harvest, this is a win.
WIN: Knowing your plants aren't coated with chemicals, raised in conditions that lead to bacterial contamination (E. Coli from spinach anyone??) and aren't artificially ripened (and nutritionally deficient)? Total win!
So, I guess my reply can be condensed in to a very helpful "it depends"
