Peel the potatoes the day before, cut into small pieces and soak vigorously overnight.
Peel the onions, cut in half and cut into half rings. Sweat the onions in oil for about 10 minutes until golden.
In the meantime, quarter the apples unpeeled and core them. Cut the quarters across into not too thin slices. Spread the apple slices over the onions. Put on the rosemary sprig and add the balsamic vinegar. Cover everything and cook on a mild heat for about 20 minutes. Season the apple and onion vegetables with salt, pepper and cane sugar and keep warm.
Pour off the watered potatoes and water again briefly with fresh water. Finely grate the watered potatoes with onions, knead with flour and season with salt and pepper. Put the potato mixture in an oiled baking dish and distribute evenly.
Bake the potatoes in a preheated oven at 175 ° C for approx. 30 minutes until golden brown.