I think you want
myxml.Descendants("S").FirstOrDefault().Add(
new XElement("R", new XAttribute("id", GetRandomId()), new XAttribute("Name", "Copyof" + myvalue),
r.First().Nodes())
if you want to copy the contents of the first item in r
or
myxml.Descendants("S").FirstOrDefault().Add(
new XElement("R", new XAttribute("id", GetRandomId()), new XAttribute("Name", "Copyof" + myvalue),
r.Nodes())
if you want to copy the contents of all items in r
.